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
<div class="tra"></div>
<div class="foo"></div>
<div class="bar"></div>
<div class="foo bar"></div>
<div class="tra foo"></div>
<script>
var l = document.getElementsByTagName("div");
re_c = {};
alert(l.length)
function re(str) {
return re_c[str] = re_c[str] || new RegExp(str);
}
function matchesClass1(list, classes) {
var x, y, ret = [],
cls;
for (x = 0; x < list.length; x++) {
cls = " " + list[x].className + " ";
for (y in classes) {
if (cls.indexOf(" " + classes[y] + " ") >= 0) {
ret.push(list[x]);
break;
}
}
}
return ret;
}
function matchesClass2(list, classes) {
var reg = re(" (" + classes.join("|") + ") "),
x, ret = [];
for (x = 0; x < list.length; x++) {
reg.test(" " + list[x].className + " ") && ret.push(list[x]);
}
return ret;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
indexOf |
| ready |
RegEx |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.