Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.push + Array.reverse vs Array.unshift
(version: 1)
Comparing performance of:
Array.push + Array.reverse vs Array.unshift
Created:
one year ago
by:
Registered User
Jump to the latest result
Script Preparation code:
const array = Array.from({length: 10_000}, () => Math.floor(Math.random() * 10_000_000))
Tests:
Array.push + Array.reverse
const temp = []; array.forEach(x => temp.push(x)); return temp.reverse();
Array.unshift
const temp = []; array.forEach(x => temp.unshift(x)); return temp;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.push + Array.reverse
Array.unshift
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.push + Array.reverse
46639.3 Ops/sec
Array.unshift
396.2 Ops/sec
Related benchmarks:
clearing array
change Float64Array vs array.push (change)
Array Entries vs fori
array.from vs spread with set
Array push vs index set
Shift vs [0]
at(-1) vs (length - 1)
Pushing vs Filling
Map.values().toArray() vs Array.from(Map.values()) vs [...Map.values()]
Comments
Confirm delete:
Do you really want to delete benchmark?