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 id="a">
</div>
<div class="b">
</div>
var get_id = function(id) {
return document.getElementById(id);
};
var get_class = function(class_name) {
return document.getElementsByClassName(class_name);
};
var SP1 = function(selector) {
if (typeof selector === 'string') {
var type = selector[0];
var label = selector.substr(1);
// id?
if (type === '#') {
return get_id(label);
// class?
} else if (type === '.') {
return get_class(label)
}
}
return selector;
}
var SP2 = function(selector) {
if (typeof selector === 'string') {
return selector[0] === '#' ? get_id(selector.substr(1)) : get_class(selector.substr(1));
}
return selector;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
SP1 |
| ready |
SP2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.