jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
var testString = '///foo/is/not/equal/to/bar///';
function normalize1(path) {
return path.replace(/^\/+|\/+$/g, '');
}
function normalize2(path) {
while (path.charAt(0) === '/') {
path = path.slice(1)
}
while (path.slice(-1) === '/') {
path = path.slice(0, -1)
}
}
function normalize3(path) {
var a = 0;
var b = path.length - 1;
while (path.charAt(a) === '/' && ++a);
while (path.charAt(b) === '/' && --b);
path = path.slice(a, b + 1);
}
function normalize4(path) {
var a = 0;
var b = path.length - 1;
while (path.charCodeAt(a) === 47 && ++a);
while (path.charCodeAt(b) === 47 && --b);
path = path.slice(a, b + 1);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
normalize1 |
| ready |
normalize2 |
| ready |
normalize3 |
| ready |
normalize4 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.