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
let ext = ""
let fname = "name.txt"
let vname = ["",
"name",
"name.txt",
".htpasswd",
"name.with.many.dots.myext"
]
function v1(fname){
return fname.slice((fname.lastIndexOf(".") - 1 >>> 0)+2);
}
function v2(fname){
return fname.slice((Math.max(0, fname.lastIndexOf(".")) || Infinity) + 1);
}
function vmine(fname) {
let len = fname.length;
for (let i = len - 1; i >= 0; i--) {
if (fname[i] == '.') {
if (i > 0) return fname.slice(i);
else return '';
break;
}
}
return '';
}
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| v1 | | ready |
| v2 | | ready |
| mio | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.