Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
push vs set length and index
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/135.0.0.0 Safari/537.36 Edg/135.0.0.0
Browser:
Chrome 135
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
push
649.6 Ops/sec
index
2651.1 Ops/sec
Tests:
push
const arr = [] const length = 100000 for(let i = 0; i < length; i++) { arr.push(i, 1) } console.log(arr[0], arr[100], arr[1000], arr[10001], arr[20000])
index
const arr = [] const length = 100000 arr.length = length*2+1 for(let i = 0; i < length; i++) { arr[i*2] = i; arr[i*2+1] = 1; } console.log(arr[0], arr[100], arr[1000], arr[10001], arr[20000])