Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Variable vs array with one item
Testing the performance impact of an array when it only contains one item
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Single element in variable
943041.9 Ops/sec
Single element in array
938461.6 Ops/sec
Script Preparation code:
const variable = document.createElement("div") const array = [document.createElement("div")] function setVariable() { variable.setAttribute("style", `transform: translate3d(${Math.random()}px, ${Math.random()}px, ${Math.random()}px)`) } function setArray() { array.forEach((elem)=>{ elem.setAttribute("style", `transform: translate3d(${Math.random()}px, ${Math.random()}px, ${Math.random()}px)`) }) }
Tests:
Single element in variable
setVariable()
Single element in array
setArray()