Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array Access vs Object Access with Random Value
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/141.0.0.0 Safari/537.36 Edg/141.0.0.0
Browser:
Chrome 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
Array
19512.0 Ops/sec
Array with Deconstruct
15459.5 Ops/sec
Object
21434.3 Ops/sec
Object with Deconstruct
41120.4 Ops/sec
Script Preparation code:
const data = Array.from({ length: 4 * 10000 }, () => Math.random()); const arr = Array(10000).fill(0); const obj = Array(10000).fill(0); for (let i = 0; i < 10000; i++) { const b = i * 4; arr[i] = [data[b], data[b + 1], data[b + 2], data[b + 3]]; obj[i] = { x: data[b], y: data[b + 1], w: data[b + 2], h: data[b + 3] }; }
Tests:
Array
let result = 0; for (let i = 0; i < 10000; i++) { result += arr[i][0] + arr[i][1] + arr[i][2] + arr[i][3]; }
Array with Deconstruct
let result = 0; for (let i = 0; i < 10000; i++) { const [x, y, w, h] = arr[i]; result += x + y + w + h; }
Object
let result = 0; for (let i = 0; i < 10000; i++) { result += obj[i].x + obj[i].y + obj[i].w + obj[i].h; }
Object with Deconstruct
let result = 0; for (let i = 0; i < 10000; i++) { const { x, y, w, h } = obj[i]; result += x + y + w + h; }