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; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Single element in variable
581840.4 Ops/sec
Single element in array
577647.2 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()