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
var reduce = function(func, init, xs) {
return xs.reduce(func, init);
};
var curry = function(fn, fnLength) {
fnLength = fnLength || fn.length;
return function() {
var suppliedArgs = Array.prototype.slice.call(arguments);
if (suppliedArgs.length >= fn.length) {
return fn.apply(this, suppliedArgs);
} else if (!suppliedArgs.length) {
return fn;
} else {
return curry(fn.bind.apply(fn, [this].concat(suppliedArgs)), fnLength - suppliedArgs.length);
}
};
};
var map = curry(function(func, xs) {
return xs.map(func);
});
var compose = function() {
var funcs = arguments;
return function() {
var args = arguments;
for (var i = funcs.length; i-- > 0;) {
args = [funcs[i].apply(this, args)];
}
return args[0];
};
};
var square = function(x) {
return x * x;
};
var add = function(a, b) {
return a + b;
};
var sum = function(s) {
return reduce(add, 0, s);
};
var length = function(xs) {
return xs.length;
};
var mean = function(xs) {
return sum(xs) / length(xs);
};
var squaredDeviations1 = function(xs) {
return map(function(x) {
return square(x - mean(xs));
}, xs);
};
var squaredDeviations2 = function(xs) {
var avg = mean(xs);
return map(function(x) {
return square(x - avg);
}, xs);
};
var set = [];
for (var i = 1; i < 1001; i++) {
set.push(i);
}
var stdev1 = compose(Math.sqrt, mean, squaredDeviations1);
var stdev2 = compose(Math.sqrt, mean, squaredDeviations2);
Ready to run.
Test | Ops/sec | |
---|---|---|
No local var |
| ready |
With local var |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.