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 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0
Browser:
Firefox 130
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
shift
1245.5M/s
pop
294.9M/s
reassignment
207.9M/s
length
81.9M/s
.splice(0)
50.4M/s
View exact numbers
Test name
Executions per second
✓
shift
1,245,452,672 Ops/sec
pop
294,933,248 Ops/sec
reassignment
207,896,912 Ops/sec
length
81,949,008 Ops/sec
.splice(0)
50,386,980 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 = []
.splice(0)
array.splice(0);