Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
clearing array via pop() vs shift() vs .length = 0 vs = []
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
shift
2371.0M/s
pop
1084.5M/s
reassignment
351.9M/s
length
113.5M/s
View exact numbers
Test name
Executions per second
✓
shift
2,371,048,448 Ops/sec
pop
1,084,503,680 Ops/sec
reassignment
351,872,928 Ops/sec
length
113,541,000 Ops/sec
Script Preparation code:
var array = []; for(var i = 0; i < 100000; i++){array.push(Math.random());}
Tests:
pop
while (array.length > 0) { array.pop(); }
shift
while (array.length > 0) { array.shift(); }
length
array.length = 0
reassignment
array = []