Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Sort and Shift vs Loop and Splice
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/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Sort and Shift
11077482.0 Ops/sec
Loop and Splice
10177517.0 Ops/sec
Script Preparation code:
var x = []; for (let i = 0; i < 1000; ++i) { x.push({ v: Math.floor(Math.random() * 1000) }); }
Tests:
Sort and Shift
x.sort((a, b) => { return a.v - b.v }); let y = x.shift();
Loop and Splice
let b = 0; for (const a in x) { if (x[a].v < x[b].v) { b = a; } } let y = x.splice(b, 1);