Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Generate Date In A Month
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Array From
13966.8 Ops/sec
new Array
15044.0 Ops/sec
Array
14938.0 Ops/sec
for push
13061.6 Ops/sec
for index
13081.0 Ops/sec
While
14238.5 Ops/sec
Tests:
Array From
function createDateArrayInAMonth(year, month) { return Array.from( { length: new Date(year, month, 0).getDate() }, (_, i) => new Date(year, month - 1, i + 1).toLocaleString() ) } createDateArrayInAMonth(2023, 10)
new Array
function createDateArrayInAMonth(year, month) { return new Array(new Date(year, month, 0).getDate()).fill().map((_, i) => new Date(year, month - 1, i + 1).toLocaleString()) } createDateArrayInAMonth(2023, 10)
Array
function createDateArrayInAMonth(year, month) { return Array(new Date(year, month, 0).getDate()).fill().map((_, i) => new Date(year, month - 1, i + 1).toLocaleString()) } createDateArrayInAMonth(2023, 10)
for push
function createDateArrayInAMonth(year, month) { const arr = [] for (let i = 0; i < new Date(year, month, 0).getDate(); i++) { arr.push(new Date(year, month - 1, i + 1).toLocaleString()) } return arr } createDateArrayInAMonth(2023, 10)
for index
function createDateArrayInAMonth(year, month) { const arr = [] for (let i = 0; i < new Date(year, month, 0).getDate(); i++) { arr[i] = new Date(year, month - 1, i + 1).toLocaleString() } return arr } createDateArrayInAMonth(2023, 10)
While
function createDateArrayInAMonth(year, month) { const date = new Date(year, month - 1, 1) const arr = [] while (date.getMonth() === month - 1) { arr.push(new Date(date).toLocaleString()) date.setDate(date.getDate() + 1) } return arr } createDateArrayInAMonth(2023, 10)