Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
get x versus array[0]
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/136.2 Mobile/15E148 Safari/605.1.15
Browser:
Mobile Safari 18
Operating system:
iOS 18.3.2
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
array[0]
76786.6 Ops/sec
set / get
75136.3 Ops/sec
Script Preparation code:
// Setup phase - common for both tests const size = 10000; const array = new Array(16).fill(1); // Fill array with ones for consistency const obj = { get x() { return array[0]; }, set x(value) { array[0] = value; } };
Tests:
array[0]
let sum = 0; for (let i = 0; i < size; i++) { array[0] = Math.random () * 1000; sum += array[0]; }
set / get
let sum = 0; for (let i = 0; i < size; i++) { obj.x = Math.random () * 1000; sum += obj.x; }