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
Jump 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
Test name
Executions per second
Object
533428.6 Ops/sec
Map
318316.2 Ops/sec
Related benchmarks:
Fibonacci vs Memo
Fib Now
Fib Now2
Fib Now 3
Fib Now 4
fibonacci
memoizer
fibonacci Recursive vs Memoization
Compare Performance to find fibonacci 2
Comments
Confirm delete:
Do you really want to delete benchmark?