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="http://code.jquery.com/jquery-1.8.2.min.js">
</script>
var i,
value,
length,
values = [],
sum = 0,
context = values;
for (i = 0; i < 10000; i++) {
values[i] = Math.random();
}
function add(val) {
sum += val;
}
function addEach(k, val) {
sum += val;
}
var toString = Object.prototype.toString;
function isArray(obj) {
return toString.call(obj) === '[object Array]';
}
function isObject(obj) {
return toString.call(obj) === '[object Object]';
}
function isString(obj) {
return toString.call(obj) === '[object String]';
}
function each(obj, iterator) {
var key, length;
if (!obj) {
return;
}
length = obj.length;
if (isArray(obj) || isString(obj)) {
for(key = 0; key < length; key += 1) {
add(obj[key], key, obj);
}
return obj;
}
if (isObject(obj)) {
for(key in obj) {
if (obj.hasOwnProperty(key)) {
add(obj[key], key, obj);
}
}
return obj;
}
return obj;
};
var aech = function() {
var arr = values,
length = arr.length;
for (var i = 0; i < length; i++) {
add(arr[i], i, arr);
}
}
function eech() {
var arr = values,
length = arr.length;
for (var i = 0; i < length; i++) {
add(arr[i], i, arr);
}
}
i = 0;
value = 0;
length = 0;
values = [];
sum = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
forEach |
| ready |
for loop, cached length, callback |
| ready |
for loop, cached length, callback.call |
| ready |
$.each |
| ready |
for loop, assignment condition, callback |
| ready |
for loop, assignment condition, callback.call |
| ready |
native map function |
| ready |
new each |
| ready |
| ready | |
| ready | |
| ready | |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.