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
return ordinal value of a number
function ordinal (a){return["th","st","nd","rd"][(a=~~(a<0?-a:a)%100)>10&&a<14||(a%=10)>3?0:a]}
function ordinalWithRegExp (a){return[,"st","nd","rd"][/1?.$/.exec(a)]||"th"}
Ready to run.
Test | Ops/sec | |
---|---|---|
original |
| ready |
ordinal with regexp |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.