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
Functions in v8 have hidden classes like objects, and functions only get fully optimized if using the default hidden class
<script type="text/javascript">
var f1 = function (n) {
return n;
};
var f2 = function (n) {
return n;
};
f2.toString = function () { return "f2"; };
Object.defineProperty(f2, "displayName", { value: "f2" });
Object.defineProperty(f2, "debugName", { value: "f2" });
Function.prototype.invoke1 = function () {
return this.apply(null, arguments);
};
Function.prototype.invoke2 = function () {
return this.apply(null, arguments);
};
Function.prototype.invoke3 = function () {
return this.apply(null, arguments);
};
var count = 5000;
// Feed information into the ICs for each function
for (var i = 0; i < count; i++) {
f1.invoke1(1);
f2.invoke2(1);
// The IC for invoke3 will get two different hidden class entries, which deoptimizes it
if (i % 2 == 0)
f1.invoke3(1);
else
f2.invoke3(1);
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Direct (unmodified) |
| ready |
Direct (modified) |
| ready |
.call (unmodified) |
| ready |
.call (modified) |
| ready |
Consistent IC information (unmodified fn) |
| ready |
Consistent IC information (modified fn) |
| ready |
Conflicting IC information (unmodified fn) |
| ready |
Conflicting IC information (modified fn) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.