Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
bind vs arrow (test2)
(version: 1)
Comparing performance of:
bind vs closure
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
bind
class Test { constructor() { this.counter = 0; } fn1() { return this.counter += 1; } fn2() { return this.counter += 2; } fn3() { return this.counter += 3; } fn4() { return this.counter += 4; } } function createSomething() { const instance = new Test(); return [instance.fn1.bind(instance), instance.fn2.bind(instance), instance.fn3.bind(instance), instance.fn4.bind(instance)]; } for (let i = 0; i < 100; i++) { let [a, b, c, d] = createSomething(); for (let j = 0; j < 100; j++) { a(); b(); c(); d(); } }
closure
class Test { constructor() { this.counter = 0; } fn1() { return this.counter += 1; } fn2() { return this.counter += 2; } fn3() { return this.counter += 3; } fn4() { return this.counter += 4; } } function createSomething() { const instance = new Test(); return [() => instance.fn1(), () => instance.fn2(), () => instance.fn3(), () => instance.fn4()]; } for (let i = 0; i < 100; i++) { let [a, b, c, d] = createSomething(); for (let j = 0; j < 100; j++) { a(); b(); c(); d(); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
bind
closure
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/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
bind
1669.2 Ops/sec
closure
1409.9 Ops/sec
Related benchmarks:
closure vs proto2
Class instance method lookup vs function-created object method lookup (fork)
Class vs bind vs hook
bind vs closure
bind vs closure v2
create class instances check method arrow vs bind vs no-bind
Time Cost for different calling
bind vs closure (forked)
bind vs arrow (test1)
Comments
Confirm delete:
Do you really want to delete benchmark?