Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
How to clear an array
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/142.0.0.0 Safari/537.36 Edg/142.0.0.0
Browser:
Chrome 142
Operating system:
Windows
Device Platform:
Desktop
Date tested:
9 months ago
splice
84K/s
while pop
69K/s
for pop
66K/s
while shift
3K/s
for shift
3K/s
View exact numbers
Test name
Executions per second
✓
splice
83,860 Ops/sec
while pop
68,772 Ops/sec
for pop
65,577 Ops/sec
while shift
2,759 Ops/sec
for shift
2,751 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const array = Array.from({ length: 10000 }, () => Math.random());
Tests:
while pop
const arr = array.slice(); while (arr.length > 0) arr.pop();
while shift
const arr = array.slice(); while (arr.length > 0) arr.shift();
for pop
const arr = array.slice(); const length = arr.length; for (let i = 0; i < length; i++) arr.pop();
for shift
const arr = array.slice(); const length = arr.length; for (let i = 0; i < length; i++) arr.shift();
splice
const arr = array.slice(); arr.splice(0);
set length
const arr = array.slice(); arr.length = 0;