Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Reading Map vs Object/Record
(version: 1)
Benchmark.js
Comparing performance of:
Map vs Object/Record
Created:
9 days ago
by:
Guest
Go to the latest result
Script Preparation code:
let map = new Map(); let obj = {}; const ENTRIES = 1000000; const LOOKUPS = 300000; const RUNS = 4; const ids = Array.from({ length: ENTRIES }, () => crypto.randomUUID()); const lookupIds = Array.from({ length: LOOKUPS }, () => ids[Math.floor(Math.random() * (ENTRIES + 1))]); for (let i = 0; i < ENTRIES; i++) { map.set(ids[i], i); obj[ids[i]] = i; }
Tests:
Map
for (let j = 0; j < RUNS; j++) { let checksum = 0; for (let i = 0; i < LOOKUPS; i++) { checksum += map.get(lookupIds[i]); } console.log(checksum); }
Object/Record
for (let j = 0; j < RUNS; j++) { let checksum = 0; for (let i = 0; i < LOOKUPS; i++) { checksum += obj[lookupIds[i]]; } console.log(checksum); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Map
Object/Record
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 days ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:155.0) Gecko/20100101 Firefox/155.0
Browser/OS:
Firefox 155 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Map
4/s
Object/Record
3/s
View exact numbers
Test name
Executions per second
✓
Map
4 Ops/sec
Object/Record
3 Ops/sec
Related benchmarks
Map vs Object 5000 rand
Map vs Object (real-world) Performance (string keys)
Get from object vs get from map
Map vs Object with 100 keys
Map vs Object with 100 keys and mutate
Map vs Object with 100 keys and 1/2 delete
Comments
Confirm delete:
Do you really want to delete benchmark?