Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
arrow vs function test llama
(version: 0)
Comparing performance of:
arrow vs binded vs simple vs assigned vs simpleChild vs assignedArrow vs pure arrow vs pure binded vs pure assigned vs pure assignedArrow
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
class A { data = 0 arrow = () => { this.data = this.data + 1 return this } binded = (function() { this.data = this.data + 1 return this }).bind(this) assigned = (() => { const self = this return function() { self.data = self.data + 1 return self } })() assignedArrow = (() => { return () => { this.data = this.data + 1 return this } })() simple() { this.data = this.data + 1 return this } } class B extends A { simpleChild() { this.data = this.data + 1 return this } } a = new A b = new B arrow = a.arrow binded = a.binded assigned = a.assigned assignedArrow = a.assignedArrow
Tests:
arrow
a.arrow()
binded
a.binded()
simple
b.simple()
assigned
a.assigned()
simpleChild
b.simpleChild()
assignedArrow
a.assignedArrow()
pure arrow
arrow()
pure binded
binded()
pure assigned
assigned()
pure assignedArrow
assignedArrow()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (10)
Previous results
Fork
Test case name
Result
arrow
binded
simple
assigned
simpleChild
assignedArrow
pure arrow
pure binded
pure assigned
pure assignedArrow
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!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down what is being tested on the provided JSON and explain the options compared, pros and cons of those approaches, other considerations, and any special JavaScript features or syntax used. **Benchmark Definition** The benchmark definition is a script that defines two classes, A and B, with some methods. The script also creates instances of these classes and assigns them to variables arrow, binded, assigned, and assignedArrow. **Options Compared** Three options are being compared: 1. `a.arrow()`: Calls the `arrow` method on instance `a`. 2. `a.binded()`: Calls the `binded` method on instance `a`, which has been bound to the context of `a` using `bind()`. 3. `b.simple()` and `b.simpleChild()`: Call the `simple` and `simpleChild` methods on instances `b` (which extends class A). **Pros and Cons** * `a.arrow()` and `a.binded()` are compared, which can help determine if binding the context to an instance affects performance. In modern JavaScript engines, binding the context is usually a cheap operation, so this benchmark may not reveal much. * `b.simple()` and `b.simpleChild()` are compared, which can help determine if inheritance has any overhead or if the methods are being called on the child class instance or the parent class prototype. **Other Considerations** * The benchmark is running on Safari 15 on a Mac with Intel hardware. This may not be representative of other browsers or platforms. * The benchmark is only measuring the execution time of the methods, without considering other factors like memory allocation or garbage collection. **Special JavaScript Features or Syntax Used** None that are immediately apparent. However, it's worth noting that the use of `bind()` to bind the context of an instance can be a performance optimization in some cases, as it avoids creating a new scope for the method call. **Conclusion** This benchmark appears to be designed to compare the performance of three different methods on two classes: one with bound context (`a.binded()`) and two without (the child class instances `b.simple()` and `b.simpleChild()`). The results may indicate whether binding the context has any overhead or if inheritance has any significant impact on performance.
Related benchmarks:
Object.assign vs mutation assign
Spread vs Object.assign (modify ) vs Object.assign (new)
JS Object assign vs object new property 2
Object assign vs empty obj
Spread vs Assign benchmark
Comments
Confirm delete:
Do you really want to delete benchmark?