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
Belonging to this question on StackOverflow.
var numsToPad=[[1,100],[-123,4],[5.619,7],[1234567890,2]];
function bailey(n,w){
w-=n.toString().length;
if(w>0)return new Array(w+(/\./.test(n)?2:1)).join('0')+n;
return str=n+"";
}
function p(n,w){
var pad=new Array(1+w).join('0');
return (pad+n).slice(-pad.length);
}
function joe(n,w){
var n_ = Math.abs(n);
var zeros = Math.max(0, w - Math.floor(n_).toString().length );
var zeroString = Math.pow(10,zeros).toString().substr(1);
if( n < 0 ) {
zeroString = '-' + zeroString;
}
return zeroString+n;
}
function lpad(input, character, length) {
if (typeof(input) == "undefined") return '';
if (typeof(length) == "undefined") length = 0;
if (typeof(character) == "undefined") character = ' ';
var padString = Array(length - input.length + 1).join(character);
return padString + input;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
Peter Bailey's |
| ready |
profitehlolz's |
| ready |
coderjoe's |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.