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="https://rawgit.com/bfontaine/tp.js/dad7cb0f5398b1afcbc481f87c0b59c7131a49ed/tp.min.js"></script>
<script>
function tco(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 tra(f) {
return function () {
var res = f.apply(this, arguments);
while (res.next != null) {
res = f.apply(null, res.next);
}
return res.result;
};
}
function nonRecursiveSum(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);
}
var sumtco = tco(function(x, y) {
return y > 0 ? sumtco(x + 1, y - 1) :
y < 0 ? sumtco(x - 1, y + 1) :
x
});
var sumtra = tra(function(x, y) {
return y > 0 ? {next: [x + 1, y - 1]} :
y < 0 ? {next: [x - 1, y + 1]} :
{result: x}
});
var sumtp = tp(function(recur) {
return function(x, y) {
return y > 0 ? recur(x + 1, y - 1) :
y < 0 ? recur(x - 1, y + 1) :
x
};
});
</script>
if (res !== 1020) throw new Error();
Ready to run.
Test | Ops/sec | |
---|---|---|
tcp |
| ready |
nrs |
| ready |
tra |
| ready |
sumtp |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.