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
Notes: As should be expected, there is little to choose between max and min.
Math.max.apply will break on large arrays, at least in chrome 11.
The browsers are all over the place on this.
Firefox 4 slows down significantly if a float is compared to an integer, even if the float isn't in the array (i.e., it was a starting value).
<script>
var data = [175, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275];
var data_float = [175, 100, -3.14, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275, 100, 300, 275];
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Math max |
| ready |
For max |
| ready |
Math min |
| ready |
For min |
| ready |
reduce max |
| ready |
reduce min |
| ready |
for + Math.max |
| ready |
for + localised Math.min |
| ready |
for + Math.min (start with inf) |
| ready |
Float data: for + Math.min (start with inf) |
| ready |
Float data: for + Math.min |
| ready |
for max -- if, no local var |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.