Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Set vs Map vs Object for lookups (1000 entries)
(version: 1)
Comparing performance of:
Object lookup vs Map lookup vs Set lookup vs Array lookup
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var list = [ "Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipisicing", "elit.", "Ullam", "nesciunt", "debitis", "facilis", "qui", "possimus", "minus", "rerum", "velit", "saepe", "magnam", "voluptatum", "quos", "eveniet", "ducimus", "facere", "harum", "itaque", "atque", "assumenda", "reiciendis", "exercitationem" ]; // Generate 970 unique random words while (list.length < 1000) { let word = Math.random().toString(36).substring(2, 10); // Generate a random word if (!list.includes(word)) { list.push(word); } } var set = new Set(list); var map = new Map(); list.forEach(word => map.set(word, true)); var object = {}; list.forEach(word => object[word] = true);
Tests:
Object lookup
var b = object["consectetur"]
Map lookup
var b = map.has("consectetur")
Set lookup
var b = set.has("consectetur")
Array lookup
var b = list.find(e => e == "consectetur")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Object lookup
Map lookup
Set lookup
Array lookup
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object lookup
68292672.0 Ops/sec
Map lookup
125513184.0 Ops/sec
Set lookup
118184440.0 Ops/sec
Array lookup
74234400.0 Ops/sec
Related benchmarks:
includes vs indexOf (Array and String)
Set vs Map vs Object for lookups
match vs include
match vs include vs indexOf
assignments vs object creation vs early return
Set vs Map vs Object for lookups vs objLookup
convert and lookup
convert and lookup 10k times
convert and lookup 10k times and 10k items
Comments
Confirm delete:
Do you really want to delete benchmark?