Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Sparse Array Vs. Object,Map,Set, Number Indexes
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/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Object
93.3 Ops/sec
Array
95.2 Ops/sec
Set Length Array
94.0 Ops/sec
TypedArray
82.5 Ops/sec
map
85.8 Ops/sec
set
80.9 Ops/sec
Script Preparation code:
var iterations =100000; var obj = {}; var arr = []; var map = new Map(); var set = new Set(); var setLengthArr = new Array(iterations); var typedArray = new Uint32Array(iterations);
Tests:
Object
for(let i=0;i<iterations;i+=10){ obj[i]=Math.floor(Math.random()*iterations); obj[i+1]=obj[i]+1; }
Array
for(let i=0;i<iterations;i+=10){ arr[i]=Math.floor(Math.random()*iterations); arr[i+1]= arr[i]+1; }
Set Length Array
for(let i=0;i<iterations;i+=10){ setLengthArr[i]=Math.floor(Math.random()*iterations); setLengthArr[i+1] = setLengthArr[i]+1; }
TypedArray
for(let i=0;i<iterations;i+=10){ typedArray[i]=Math.floor(Math.random()*iterations); typedArray[i+1]= typedArray[i]+1; }
map
for(let i=0;i<iterations;i+=10){ map.set(i,Math.floor(Math.random()*iterations)); map.set(i+1,map.get(i)+1) }
set
for(let i=0;i<iterations;i+=10){ set.add(Math.floor(Math.random()*iterations)); set.add(set.has(i+1)) }