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
Testing popular answers to SO question http://stackoverflow.com/questions/6312993/javascript-seconds-to-time-with-format-hhmmss
var simpleFormatter = function(ms) {
var seconds = parseInt(ms / 1000);
var hh = Math.floor(seconds / 3600);
var mm = Math.floor((seconds - (hh * 3600)) / 60);
var ss = seconds - (hh * 3600) - (mm * 60);
if (hh < 10) {
hh = '0' + hh
}
if (mm < 10) {
mm = '0' + mm
}
if (ss < 10) {
ss = '0' + ss
}
return hh + ':' + mm + ':' + ss;
};
var regExpFormatter = function(ms) {
return new Date(ms).toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
};
var dateObjFormatter = function(ms) {
var date = new Date(ms);
var hh = date.getHours();
var mm = date.getMinutes();
var ss = date.getSeconds();
if (hh < 10) {
hh = '0' + hh
}
if (mm < 10) {
mm = '0' + mm
}
if (ss < 10) {
ss = '0' + ss
}
return hh + ':' + mm + ':' + ss;
};
Ready to run.
Test | Ops/sec | |
---|---|---|
simpleFormatter |
| ready |
regExpFormatter |
| ready |
dateObjFormatter |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.