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
Native max vs my max
<script>
function mymax(a, b, c) {
if (a > b) {
if (a > c) return a;
return c;
}
if (b > c) return b;
return c;
}
function ternary(a, b, c) {
return (a > b) ? a > c ? a : c : b > c ? b : c;
}
function maximax (a, b, c) { return Math.max(Math.max(a,b),c); }
function test(f, n) {
var s = 0, x = n / 2;
for (var i = 0; i < n; ++i)
for (var j = 0; j < n; ++j)
s += f(i, j, x);
}
var n = 6
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
mymax |
| ready |
Math.max |
| ready |
maximax |
| ready |
ternary |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.