Created
March 5, 2020 04:09
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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