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
<script>
// http://twitter.com/cowboy/status/15344233981
function pad(n, d) {
return Array(Math.max(0, d - (n + '').length + 1)).join(0) + n;
};
// http://www.electrictoolbox.com/pad-number-zeroes-javascript/
function pad2(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
};
return str;
};
function pad3(n, d) {
return ((Math.pow(10, d) + n) + '').substr(1);
};
function pad4(n, d) {
return ('00000000000000' + n).slice(-d);
}
// pad2 with cached padLength
function pad5(n, d) {
var padLength = d - ('' + n).length;
if (padLength > 0) {
while (padLength--) {
n = '0' + n;
}
}
return n;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Ben Alman’s pad() function |
| ready |
The pad2() function |
| ready |
The pad3() function |
| ready |
The pad4() function |
| ready |
The pad5() function |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.