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>
var UID = 0;
</script>
// Need to generate core of the benchmark dynamically to ensure
// that type feedback does not leak between individual sample runs.
var code = " /* " + (UID++) + " */ " + " for (var i = 0; i < N; i++) {" +
" var obj = arr[i];" +
" result += obj.x + obj.y + i;" +
"}" +
"return result";
var f = new Function("N, arr, result", code);
var K = 10;
var objs = [];
for (var i = 0; i < (K / 2); i++) {
objs.push(new function () {
this.x = 0;
this.y = 0;
} ());
}
for (var i = 0; i < (K / 2); i++) {
objs.push(new function () {
this.y = 0;
this.x = 0;
} ());
}
var mono = [],
poly = [],
poly2 = [],
mega = [];
var N = 20;
for (var i = 0; i < N; i++) {
mono.push(objs[0])
poly.push(objs[i % 3])
poly2.push(objs[(i % 3) || (K / 2)])
mega.push(objs[i % 6])
}
var result = 0;
if (result < 0) throw "";
Ready to run.
Test | Ops/sec | |
---|---|---|
calling monomorphic function |
| ready |
calling polymorphic |
| ready |
calling megamorphic |
| ready |
poly (different property offsets) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.