Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map and Object number key vs string key
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Browser:
Firefox 148
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
Integer
82.2 Ops/sec
Float
82.3 Ops/sec
String
41.7 Ops/sec
Integer with Object
56.1 Ops/sec
Float with Object
22.2 Ops/sec
String with Object
31.0 Ops/sec
Script Preparation code:
var map = new Map(); var obj = {}; var randomInteger = Array(100000).fill(0).map(v => Math.floor(Math.random() * 1e8)); var randomFloat = Array(100000).fill(0).map(v => Math.random() * 1e8); var randomString = Array(100000).fill(0).map(v => (Math.random() * 1e8).toString());
Tests:
Integer
map.clear(); randomInteger.forEach(v => { map.set(v, Math.random()); map.get(v); });
Float
map.clear(); randomFloat.forEach(v => { map.set(v, v); map.get(v); });
String
map.clear(); randomString.forEach(v => { map.set(v, v); map.get(v); });
Integer with Object
obj = {}; randomInteger.forEach(v => { obj[v] = v; obj[v]; });
Float with Object
obj = {}; randomFloat.forEach(v => { obj[v] = v; obj[v]; });
String with Object
obj = {}; randomString.forEach(v => { obj[v] = v; obj[v]; });