Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
call vs prop & array vs map for both
(version: 0)
Comparing performance of:
call (Array) vs call (Map) vs prop (Array) vs prop (Map)
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
class Foobar { constructor () { this.n = 1 this.funcs = [this.foo, this.bar, this.baz] this.funcMap = new Map(this.funcs.map((func, i) => [i, func])) this.props = ['foo', 'bar', 'baz'] this.propMap = new Map(this.props.map((prop, i) => [i, prop])) } foo () { this.n *= 2 } bar () { this.n *= 3 } baz () { this.n /= 4 } } var foobar = new Foobar()
Tests:
call (Array)
for (let i = 0; i < 100; i += 1) { foobar.funcs[i % 3].call(foobar) }
call (Map)
for (let i = 0; i < 100; i += 1) { foobar.funcMap.get(i % 3).call(foobar) }
prop (Array)
for (let i = 0; i < 100; i += 1) { foobar[foobar.props[i % 3]]() }
prop (Map)
for (let i = 0; i < 100; i += 1) { foobar[foobar.propMap.get(i % 3)]() }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
call (Array)
call (Map)
prop (Array)
prop (Map)
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
in vs direct call
Object.assign vs direct assign
ForOf+Push vs Map
from vs map
Explode vs assignation
Comments
Confirm delete:
Do you really want to delete benchmark?