Test name | Executions per second |
---|---|
Parse Date | 49.3 Ops/sec |
String split | 82.9 Ops/sec |
var dateStrings = Array(10000).fill(null).map(() => (new Date()).toISOString());
var padDate = date => (date < 10 ? `0${date}` : date);
dateStrings.map((d) => {
const date = new Date(d);
return `${padDate(date.getDate())}.${padDate(date.getMonth() + 1)}.${padDate(date.getYear())}`;
});
dateStrings.map((d) => {
const [date, time] = d.split('T')
const [year, month, day] = date.split('-');
return `${day}.${month}.${year}`;
});