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
<p id="foo">Foo</p>
<p id="bar">Bar</p>
<p id="baz">Baz</p>
var $ = $ || {};
$ = function(selector, context) {
var elements = (context || document).querySelectorAll(selector);
return (elements.length > 0)? elements : null;
};
$.filterOperators = [
{"o": "EQUALS", "c": "=", "label": "equals"},
{"o": "CONTAINS", "c": "*=", "label": "contains"},
{"o": "STARTS_WITH", "c": "^=", "label": "starts with"},
{"o": "ENDS_WITH", "c": "$=", "label": "ends with"}
];
$.getOperator = function ( k ) {
fo= $.filterOperators;
for ( var i = 0, n = fo.length; i < n; i++ ) {
var o = fo[i].o,
c = fo[i].c;
if (o.toLocaleLowerCase() == k.toLocaleLowerCase()) return c;
}
};
$.id = function(id) {
var element;
if (document.getElementById)
element = document.getElementById(id);
else if (document.all)
element = window.document.all[id];
else if (document.layers)
element = window.document.layers[id];
return (element)? element : null;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
getElementById with condition |
| ready |
querySelector with condition |
| ready |
querySelector without condition |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.