Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
WeakMap vs "Symbol with WeakMap fallback"
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0
Browser:
Firefox 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Symbol with WeakMap fallback get
314.2M/s
Symbol with WeakMap fallback set
259.8M/s
WeakMap get
35.0M/s
WeakMap set
19.4M/s
View exact numbers
Test name
Executions per second
✓
Symbol with WeakMap fallback get
314,160,640 Ops/sec
Symbol with WeakMap fallback set
259,768,816 Ops/sec
WeakMap get
35,020,544 Ops/sec
WeakMap set
19,382,890 Ops/sec
Script Preparation code:
var c = Symbol === undefined ? (function() { var x = function() { this._x = new WeakMap(); } x.prototype.get = function(x) { return this._x.get(x); }; x.prototype.set = function(x,y) { this._x.set(x,y); }; return x; })() : (function() { var x = function() { this._x = Symbol(); } x.prototype.get = function(x) { return x[this._x]; }; x.prototype.set = function(x,y) { x[this._x] = y; }; return x; })(); var to0 = {}; var to1 = {}; var wm = new WeakMap(); var fwm = new c(); wm.set(to1, 1); fwm.set(to1, 1);
Tests:
WeakMap get
let r = wm.get(to1);
Symbol with WeakMap fallback get
let r = fwm.get(to1);
WeakMap set
wm.set(to0, 1);
Symbol with WeakMap fallback set
fwm.set(to0, 1);