Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map.has vs Object hasOwnProperty vs direct check v2
Lookup of map vs object
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/138.0.0.0 Safari/537.36 Edg/138.0.0.0
Browser:
Chrome 138
Operating system:
Linux
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
Map lookup
3164.4 Ops/sec
Obj lookup
3033.0 Ops/sec
direct check
3247.7 Ops/sec
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 lookup
for (i = 0; i < count; i++) { a = map.has('stringKey'); }
Obj lookup
for (i = 0; i < count; i++) { a = obj.hasOwnProperty('stringKey'); }
direct check
for (i = 0; i < count; i++) { a = obj['stringKey'] != null }