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"}
function ordinalMapReduce (b){b=(b+"").split("").slice(-2).reduce(function(d,c){if(1==d){return 0;}else{return c>3?0:c;}});return["th","st","nd","rd"][b];}
Ready to run.
Test | Ops/sec | |
---|---|---|
ordinal |
| ready |
ordinal with regexp |
| ready |
ordinal with map reduce |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.