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; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
while pop
31259.2 Ops/sec
while shift
7306.0 Ops/sec
for pop
33444.1 Ops/sec
for shift
7487.5 Ops/sec
splice
83091.4 Ops/sec
set length
105243.0 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;