Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Map vs WeakMap
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
Map
168248128.0 Ops/sec
WeakMap
167431136.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const getInt = (()=>{r=Math.random;f=Math.floor;return (a=0,b=0x100000000)=>f(r()*(b-a))+a})(); const getStr = (()=>{ const f = (n)=> n < 10 ? 0x30 + n : n < 36 ? 0x41 + (n - 10) : 0x61 + (n - 36); return (n)=> String.fromCharCode(...(new Int32Array(n)).map(()=>f(getInt(0,62)))); })(); const keys = []; const N = 0x40000; const map = new Map(); const weakmap = new WeakMap(); for(i=0;i<N;i++){ let key = {i}; let value = getInt(); map.set(key,value); weakmap.set(key,value); keys[i] = key; }
Tests:
Map
var a = map.get(keys[getInt(0,N)]);
WeakMap
var a = weakmap.get(keys[getInt(0,N)]);