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
In V8 in particular, many functions may be valid for various input types. When you pass in different "types" into a function, you are causing that function to be polymorphic which is more difficult to optimize. Here we test the classic "add" function which uses the overloaded "+" operator in javascript to either sum numbers of concatenate strings.
var addMono = function (a,b) { return a + b }
var addPoly = function (a,b) { return a + b }
/*
here we "prime" V8 by actually using our functions. This flips internal switches inside the inline-class information for these functions.
*/
var dummy1 = addMono(1,2)
var dummy2 = addPoly(1,2)
var dummy3 = addPoly("mr", "bean")
Ready to run.
Test | Ops/sec | |
---|---|---|
monomorphic |
| ready |
polymorphic |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.