Skip to content

Instantly share code, notes, and snippets.

@tiendq
Created March 5, 2020 04:09
Show Gist options
  • Save tiendq/133948d9ff3effa82f71675c30ede394 to your computer and use it in GitHub Desktop.
Save tiendq/133948d9ff3effa82f71675c30ede394 to your computer and use it in GitHub Desktop.
let seedDate = Date.now();
let sampleDateStrings = [];
let sampleDateValues = [];
const TOTAL_SAMPLE = 1000000;
for (let i = 0; i < TOTAL_SAMPLE; ++i) {
sampleDateStrings.push((new Date(seedDate + i)).toISOString());
sampleDateValues.push(seedDate + i);
}
function testDate(samples) {
let start = Date.now();
for (let i = 0; i < samples.length; ++i) {
let d = new Date(samples[i]);
}
let end = Date.now();
return end - start;
}
console.log('Date string: %d', testDate(sampleDateStrings));
console.log('Date value: %d', testDate(sampleDateValues));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment