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
Tests if passing a date as a string vs parsing the string via regex might grant better performance
var timestamp = '2000/01/01 00:00:00',
dates = [],
total = 1000,
i = 0,
pattern = new RegExp('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2})\.([0-9]{1,2})');
var makeNiceDate = function(date, len){
len = len || 2;
return String("0"+date).slice(-len);
}
while(i < total){
var d = new Date(timestamp);
d.setDate(i);
dates.push("" + makeNiceDate(d.getFullYear(), 4) + "-" + makeNiceDate(d.getMonth()+1) + "-" + makeNiceDate(d.getDate()) + " " + makeNiceDate(d.getHours()) + ":" + makeNiceDate(d.getMinutes()) + "." + makeNiceDate(d.getSeconds()));
i++;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Automatic Parse |
| ready |
Regex Parse |
| ready |
Slice Parse |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.