Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
unshift vs sort
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 134
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Benchmark engine:
Benchmark.js
swapping
6K/s
unshift
6/s
View exact numbers
Test name
Executions per second
✓
swapping
5,666 Ops/sec
unshift
6 Ops/sec
Script Preparation code:
var arr = [...Array(10000)].map((_,i) => i)
Tests:
unshift
arr.forEach((v,i) => { console.log(v,i); arr.unshift(arr.splice(i,1).shift()) })
swapping
arr.sort((a,b) => (a === b) ? 0 : (a < b) ? 1 : -1)