Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map get vs object get by key
(version: 1)
map get vs object get by key
Comparing performance of:
map get vs object by key
Created:
one month ago
by:
Guest
Jump to the latest result
Script Preparation code:
var map = new Map(); var obj = {}; var j = 0; while (j < 10000) { var key = "Key_" + j; map.set(key, 5); obj[key] = 5; j += 1; } var stringKey = 'asdfasdjfa;sjfjaklfjklsjklajjjj;jlsjfajdfsfjs;fjsfka'; var i = 0, count = 1000, a;
Tests:
map get
for (i = 0; i < count; i++) { a = map.get('Key_' + i); }
object by key
for (i = 0; i < count; i++) { a = obj['Key_' + i]; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
map get
object by key
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Browser/OS:
Chrome 147 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
map get
8832.6 Ops/sec
object by key
13703.6 Ops/sec
Related benchmarks:
ObjectVMap
Access Object, Map, Set
Map vs Object (2)
Map vs Object (3)
Map vs Object - Multiple keys
Map get VS Map has get2
Map get VS Map has get3
Map.has vs Object hasOwnProperty
Map.has vs Object hasOwnProperty vs direct check v2
Comments
Confirm delete:
Do you really want to delete benchmark?