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
const number = Math.random() * 1000
const fixToOneA = num => (num = ((num * 10)|0) / 10) + (num === (num|0) ? '.0' : '')
const fixToTwoA = num =>
(num = (((num * 100)|0) / 100) +
(num === (num|0) ? '.0' : 0)) + (num === (num|0) ? '.0' : '') +
(num * 10 === ((num * 10)|0) ? '0' : '')
const fixToOneB = num => ~~num + '.' + ~~((num *= 10) % 10)
const fixToTwoB = num => ~~num + '.' + ~~((num *= 10) % 10) + ~~((num *= 10) % 10)
Ready to run.
Test | Ops/sec | |
---|---|---|
toFixed 1 |
| ready |
Function 2 A |
| ready |
Function 1 A |
| ready |
Function 1 B |
| ready |
Function 2 B |
| ready |
toFixed 2 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.