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
An experiment with the performance of different ABIs for polymorphic code
function foo(a, add, mul) {
return mul(add(a, a), a);
}
const add_s = Symbol();
const mul_s = Symbol();
function foo2(a, v) {
const add = v[add_s];
const mul = v[mul_s];
return mul(add(a, a), a);
}
function foo3(a) {
return a[mul_s](a[add_s](a), a);
}
const v = 12;
const add = function(n, m) { return n + m; }
const mul = function(n, m) { return n * m; }
const proto = { [add_s]: add, [mul_s]: mul };
const vt = Object.create(proto)
class MyNumber extends Number {}
MyNumber.prototype[add_s] = add;
MyNumber.prototype[mul_s] = mul;
const v_number = new Number(v);
const v_mynumber = new MyNumber(v);
Ready to run.
Test | Ops/sec | |
---|---|---|
Directly passing functions |
| ready |
Via vtable |
| ready |
Via VTable + hidden class optimization |
| ready |
As object |
| ready |
As object via own prototype |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.