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 i,
value,
length,
values = [],
sum = 0,
context = values;
for (i = 0; i < 10000; i++) {
values[i] = Math.random();
}
function add(val) {
sum += val;
}
function my_for_each(A, f)
{
for(var k = 0, m = A.length; k<m; k++)
f(A[k], k, A)
}
function my_for_each2(A, f)
{
for(var k = 0, m = A.length; k<m; k++)
if(k in A) f(A[k], k, A)
}
function my_for_each3(A, f, that)
{
for(var k = 0, m = A.length; k<m; k++)
if(k in A) {
if (that) f.call(that, A[k], k, A)
else f(A[k], k, A)
}
}
function my_for_each4(A, f, that)
{
for(var k = 0, m = A.length; k<m; k++)
if(k in A) {
f.call(that, A[k], k, A)
}
}
var GLOBAL = function () {return this} ();
var emptyy = {};
function my_for_each5(A, f, that)
{
// if (!that) that = GLOBAL;
if (!that) that = emptyy;
var id = '_' + performance.now();
that[id] = f;
for(var k = 0, m = A.length; k<m; k++)
if(k in A)
{
that[id](A[k], k, A)
}
delete that[id];
}
function my_for_each6(A, f, that)
{
if (that !== undefined) f = f.bind(that);
for(var k = 0, m = A.length; k<m; k++)
if(k in A) f(A[k], k, A)
}
i = 0;
value = 0;
length = 0;
values = [];
sum = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
forEach |
| ready |
for loop, cached length |
| ready |
for loop, assignment condition |
| ready |
forEach without cache |
| ready |
personal foreach |
| ready |
perso2 (more general) |
| ready |
perso3 |
| ready |
perso4 as in the specs (by use) |
| ready |
perso5 |
| ready |
perso6 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.