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
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="container"></div>
<script>
var container = document.getElementById("container");
var selecthash = {
"#": "getElementById",
".": "getElementsByClassName"
};
function select2(selector, context) {
var c = selector.charAt(0),
method = selecthash[c];
if (method) {
selector = selector.substr(1);
} else {
method = "getElementsByTagName"
}
return (context || document)[method](selector);
}
function select(selector, context) {
var c = selector.charAt(0),
method;
if (c === "#") {
method = "getElementById";
selector = selector.substr(1);
} else if (c === ".") {
method = "getElementsByClassName";
selector = selector.substr(1);
} else {
method = "getElementsByTagName";
}
return (context || document)[method](selector);
}
var By = {
id: function _byId(id) {
return document.getElementById(id);
},
tag: function _byTag(tag, context) {
return (context || document).getElementsByTagName(tag);
},
"class": function _byClass(klass, context) {
return (context || document).getElementsByClassName(klass);
}
};
function select3(selector, context) {
var c = selector.charAt(0),
context = context || document;
if (c === '#') {
return context.getElementById(selector.substr(1));
} else if (c === '.') {
return context.getElementsByClassName(selector.substr(1));
} else {
return context.getElementsByTagName(selector);
}
}
var byId = By.id;
var byClass = By.class;
var byTag = By.tag;
var byId2 = document.getElementById.bind(document);
</script>
container.innerHTML = '<div></div><div id="foo"></div><div class="bar"></div>';
container.innerHTML = "";
Ready to run.
Test | Ops/sec | |
---|---|---|
native |
| ready |
select |
| ready |
QSA |
| ready |
By |
| ready |
jQuery |
| ready |
select2 |
| ready |
select3 |
| ready |
local |
| ready |
local2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.