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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
array[0]
10427.7 Ops/sec
set / get
1151.4 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; }