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="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js">
</script>
<script>
var a = $('*').get(),
e, breaker = {};
var myEach = function(obj, iterator, context) {
if (obj == null) return obj;
if (obj.length === +obj.length) {
for (var i = 0, length = obj.length; i < length; i++) {
iterator.call(context, obj[i]);
}
} else {
var keys = _.keys(obj);
for (var i = 0, length = keys.length; i < length; i++) {
iterator.call(context, obj[keys[i]], keys[i], obj);
}
}
return obj;
};
var myEachSmartContext = function(obj, iterator, context) {
if (context) {
return myEach(obj, iterator, context);
}
if (obj == null) return obj;
if (obj.length === +obj.length) {
for (var i = 0, length = obj.length; i < length; i++) {
if (iterator(obj[i])) return;
}
} else {
var keys = _.keys(obj);
for (var i = 0, length = keys.length; i < length; i++) {
iterator(obj[keys[i]], keys[i]);
}
}
return obj;
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
jQuery.each |
| ready |
for loop |
| ready |
native forEach |
| ready |
native forEach (right args) |
| ready |
no context underscore |
| ready |
non-native underscore |
| ready |
underscore.each |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.