Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Shuffled Array Cache Test 3
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/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Shuffled
25.0 Ops/sec
Shuffled const
25.9 Ops/sec
Sorted
67.9 Ops/sec
Sorted const
69.0 Ops/sec
Script Preparation code:
var sorted = new Array(200000); var shuffled = new Array(200000); class Vector { constructor() { this.x = 0; this.y = 0; this.z = 0; } } for (let i=0; i<200000; i++) { const obj = { position: new Vector(), scale: new Vector(), rotation: new Vector() }; sorted[i] = obj; shuffled[i] = obj; } for (let i=0; i<200000; i++) { const index = Math.floor(Math.random() * 200000); const temp = shuffled[i]; shuffled[i] = shuffled[index]; shuffled[index] = temp; }
Tests:
Shuffled
for (let i=0; i<200000; i++) { const obj = shuffled[i]; if (obj.position.x === 0 && obj.position.y === 0 && obj.position.z === 0) {} }
Shuffled const
for (let i=0; i<200000; i++) { const obj = shuffled[i]; const position = obj.position; if (position.x === 0 && position.y === 0 && position.z === 0) {} }
Sorted
for (let i=0; i<200000; i++) { const obj = sorted[i]; if (obj.position.x === 0 && obj.position.y === 0 && obj.position.z === 0) {} }
Sorted const
for (let i=0; i<200000; i++) { const obj = sorted[i]; const position = obj.position; if (position.x === 0 && position.y === 0 && position.z === 0) {} }