Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
slice VS splice VS pop for fixed size list of objects
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
pop-for
4.5M/s
pop-while
4.4M/s
splice
3.9M/s
slice
206K/s
View exact numbers
Test name
Executions per second
✓
pop-for
4,499,114 Ops/sec
pop-while
4,422,205 Ops/sec
splice
3,937,157 Ops/sec
slice
206,015 Ops/sec
Script Preparation code:
var list = []; for (let i = 0; i < 1000; i++) { list.push({'s':'usd', 'p':i}); }
Tests:
slice
list.unshift({'s':'cad', 'p':13}) list.unshift({'s':'cad', 'p':14}) list.unshift({'s':'cad', 'p':15}) if(list.length>1000){ list=list.slice(0, 1000) }
splice
list.unshift({'s':'cad', 'p':13}) list.unshift({'s':'cad', 'p':14}) list.unshift({'s':'cad', 'p':15}) if(list.length>1000){ list.splice(1000, list.length); }
pop-while
list.unshift({'s':'cad', 'p':13}) list.unshift({'s':'cad', 'p':14}) list.unshift({'s':'cad', 'p':15}) while(list.length>1000){ list.pop(); }
pop-for
list.unshift({'s':'cad', 'p':13}) list.unshift({'s':'cad', 'p':14}) list.unshift({'s':'cad', 'p':15}) for(let i=998; i<list.length; i++){ list.pop(); }