Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map.has vs Map.get
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
has
5284.9 Ops/sec
get
6155.0 Ops/sec
HTML Preparation code:
<div id=''></div>
Script Preparation code:
const map = new Map(); map.set("foo", 1); const map1 = new Map(); map1.set("foo", 1); let count = 10000;
Tests:
has
const map = new Map(); map.set("foo", 1); for(let i = 0; i < 10000; i ++){ if(map.has("foo")){ map.set("foo", map.get("foo") + 1); } }
get
const map1 = new Map(); map1.set("foo", 1); for(let i = 0; i < 10000; i ++){ const num = map1.get("foo"); if(num){ map1.set("foo", num + 1); } }