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
Just doing some benchmarks.
<script src="//rawgithub.com/lodash/lodash/9bb9cee4cbf4e4780ba4a16dae717ccaf344dd5b/dist/lodash.js"></script>
var _ = window._,
a = _.shuffle(_.range(1000));
function process(i) {
return i * i + i;
}
// angular.map (1.3.0.rc2)
var isArray = Array.isArray;
function isString(value){return typeof value === 'string';}
function isFunction(value){return typeof value === 'function';}
function isObject(value){
// http://jsperf.com/isobject4
return value !== null && typeof value === 'object';
}
function isWindow(obj) {
return obj && obj.window === obj;
}
function isArrayLike(obj) {
if (obj == null || isWindow(obj)) {
return false;
}
var length = obj.length;
if (obj.nodeType === 1 && length) {
return true;
}
return isString(obj) || isArray(obj) || length === 0 ||
typeof length === 'number' && length > 0 && (length - 1) in obj;
}
function forEach(obj, iterator, context) {
var key, length;
if (obj) {
if (isFunction(obj)) {
for (key in obj) {
// Need to check if hasOwnProperty exists,
// as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
iterator.call(context, obj[key], key, obj);
}
}
} else if (isArray(obj) || isArrayLike(obj)) {
var isPrimitive = typeof obj !== 'object';
for (key = 0, length = obj.length; key < length; key++) {
if (isPrimitive || key in obj) {
iterator.call(context, obj[key], key, obj);
}
}
} else if (obj.forEach && obj.forEach !== forEach) {
obj.forEach(iterator, context, obj);
} else {
for (key in obj) {
if (obj.hasOwnProperty(key)) {
iterator.call(context, obj[key], key, obj);
}
}
}
}
return obj;
}
function map(obj, iterator, context) {
var results = [];
forEach(obj, function(value, index, list) {
results.push(iterator.call(context, value, index, list));
});
return results;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
angular.map |
| ready |
Array.map |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.