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>
function tco1(f) {
var active = false, value, accumulated, args
return function accumulator() {
accumulated = arguments
if (!active) {
active = true
while (accumulated) {
args = accumulated
accumulated = null
value = f.apply(this, args)
}
active = false
return value
}
}
}
function tco2(fn) {
var active, nextArgs;
return function() {
var result;
nextArgs = arguments;
if (!active) {
active = true;
while (nextArgs) {
result = fn.apply(this, [nextArgs, nextArgs = null][0]);
}
active = false;
}
return result;
};
}
function tco3(fn) {
var active, nextArgs;
return function() {
var args, result;
nextArgs = arguments;
if (!active) {
active = true;
while (nextArgs) {
args = nextArgs;
nextArgs = null;
result = fn.apply(this, args);
}
active = false;
}
return result;
};
}
function tco4(fn) {
var queue;
return function() {
var args, result;
if (queue) {
queue.push(arguments);
} else {
queue = [arguments];
while ((args = queue.pop())) {
result = fn.apply(this, args);
}
queue = null;
}
return result;
};
}
function tco5(fn) {
var queue;
return function() {
var args, result, index = 0;
if (queue) {
queue[queue.length] = arguments;
} else {
queue = [arguments];
while ((args = queue[index++])) {
result = fn.apply(this, args);
}
queue = null;
}
return result;
};
}
function tco6(f) {
var value, active = false, accumulated = []
return function accumulator() {
accumulated.push(arguments)
if (!active) {
active = true
while (accumulated.length) value = f.apply(this, accumulated.shift())
active = false
return value
}
}
}
function nonRecursiveSum1(x, y) {
var args, queue = [{ 'x': x, 'y': y }];
do {
args = queue.pop();
x = args.x;
y = args.y;
if (y > 0) {
queue.push({ 'x': x + 1, 'y': y - 1 });
} else if (y < 0) {
queue.push({ 'x': x - 1, 'y': y + 1 });
} else {
return x;
}
} while (true);
}
function nonRecursiveSum2(x, y) {
var args, index = 0, queue = [{ 'x': x, 'y': y }];
do {
args = queue[index++];
x = args.x;
y = args.y;
if (y > 0) {
queue[queue.length] = { 'x': x + 1, 'y': y - 1 };
} else if (y < 0) {
queue[queue.length] = { 'x': x - 1, 'y': y + 1 };
} else {
return x;
}
} while (true);
}
function nonRecursiveSum3(x, y) {
var args, index = 0, queue = [[x, y]];
do {
args = queue[index++];
x = args[0];
y = args[1];
if (y > 0) {
queue[queue.length] = [x + 1, y - 1];
} else if (y < 0) {
queue[queue.length] = [x - 1, y + 1];
} else {
return x;
}
} while (true);
}
function nonRecursiveSum4(x, y) {
var args, queue = [[x, y]];
do {
args = queue.pop();
x = args[0];
y = args[1];
if (y > 0) {
queue.push([x + 1, y - 1]);
} else if (y < 0) {
queue.push([x - 1, y + 1]);
} else {
return x;
}
} while (true);
}
</script>
var sum1 = tco1(function(x, y) {
return y > 0 ? sum1(x + 1, y - 1) :
y < 0 ? sum1(x - 1, y + 1) :
x
});
var sum2 = tco2(function(x, y) {
return y > 0 ? sum2(x + 1, y - 1) :
y < 0 ? sum2(x - 1, y + 1) :
x
});
var sum3 = tco3(function(x, y) {
return y > 0 ? sum3(x + 1, y - 1) :
y < 0 ? sum3(x - 1, y + 1) :
x
});
var sum4 = tco4(function(x, y) {
return y > 0 ? sum4(x + 1, y - 1) :
y < 0 ? sum4(x - 1, y + 1) :
x
});
var sum5 = tco5(function(x, y) {
return y > 0 ? sum5(x + 1, y - 1) :
y < 0 ? sum5(x - 1, y + 1) :
x
});
var sum6 = tco6(function(x, y) {
return y > 0 ? sum6(x + 1, y - 1) :
y < 0 ? sum6(x - 1, y + 1) :
x
});
function sum7(_x, _x2) {
var _arguments = arguments,
_this = this;
_function: while (true) {
var x = _arguments[0],
y = _arguments[1];
if (y > 0) {
_arguments = [x + 1, y - 1];
_this = undefined;
continue _function;
} else if (y < 0) {
_arguments = [x - 1, y + 1];
_this = undefined;
continue _function;
} else {
return x;
}
};
}
function sum8(_x, _x2) {
var _arguments = arguments,
_this = this;
_function: while (true) {
var x = _x,
y = _x2;
if (y > 0) {
_arguments = [_x = x + 1, _x2 = y - 1];
_this = undefined;
} else if (y < 0) {
_arguments = [_x = x - 1, _x2 = y + 1];
_this = undefined;
} else {
return x;
}
};
}
var nonRecursiveSum1 = window.nonRecursiveSum1;
var nonRecursiveSum2 = window.nonRecursiveSum2;
var nonRecursiveSum3 = window.nonRecursiveSum3;
var nonRecursiveSum4 = window.nonRecursiveSum4;
Ready to run.
Test | Ops/sec | |
---|---|---|
tco1 |
| ready |
tco2 |
| ready |
tco3 |
| ready |
tco4 |
| ready |
tco5 |
| ready |
tco6 |
| ready |
nrs1 |
| ready |
nrs2 |
| ready |
nrs3 |
| ready |
nrs4 |
| ready |
6to5 TCO 1 |
| ready |
6to5 TCO 2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.