Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Memoization (Object, WeakMap)
(version: 0)
Comparing performance of:
Object vs Map
Created:
one year ago
by:
Registered User
Go to the latest result
Tests:
Object
const memo = {} function fibonacci(n) { if (n <= 1) return n; if (memo[n]) return memo[n] memo[n] = fibonacci(n-1) + fibonacci(n-2) return memo[n] } fibonacci(40)
Map
const cache = new Map(); function fibonacci(n) { if (n <= 1) return n; if (cache.has(n)) { return cache.get(n); } cache.set(n, fibonacci(n-1) + fibonacci(n-2)) return cache.get(n) } fibonacci(40)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object
Map
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Object
533K/s
Map
318K/s
View exact numbers
Test name
Executions per second
✓
Object
533,429 Ops/sec
Map
318,316 Ops/sec
Related benchmarks
Fib Now 3
Comments
Confirm delete:
Do you really want to delete benchmark?