Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Noop vs new arrow function calls
(version: 0)
Comparing performance of:
Noop vs New arrow function
Created:
3 years ago
by:
Guest
Go to the latest result
Script Preparation code:
window.noop = () => {};
Tests:
Noop
const func = noop; func();
New arrow function
const func = () => {}; func();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Noop
New arrow function
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
New arrow function
235.4M/s
Noop
20.8M/s
View exact numbers
Test name
Executions per second
✓
New arrow function
235,380,416 Ops/sec
Noop
20,762,566 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and its results. **Benchmark Overview** The benchmark measures the performance difference between two approaches: `noop` (a traditional function call) and a new arrow function (`() => {}`) in JavaScript. **Options Compared** The benchmark compares the execution speed of two approaches: 1. **Traditional function call**: Using the `noop` variable, which is set to an empty function using `window.noop = () => {};`. This approach calls the `noop` function directly. 2. **Arrow function**: Using a new arrow function, defined as `const func = () => {};`, and then calling it. **Pros and Cons of Each Approach** 1. **Traditional Function Call (Noop)**: * Pros: Easy to understand and implement, familiar syntax for most developers. * Cons: May incur additional overhead due to the function call itself, potential cache misses if the function is not inlined. 2. **Arrow Function**: * Pros: More concise and readable, potentially faster execution due to reduced overhead of function calls (no `this` binding, no explicit return type). * Cons: May be less familiar to some developers, potential issues with arrow functions and their scoping. **Library and Purpose** The benchmark uses the `window.noop` variable, which is a global object used in older browsers to create a placeholder function. Its purpose is to provide a way to test function call performance without affecting other code execution. **Special JS Feature/Syntax** There are no special JavaScript features or syntaxes used in this benchmark. **Alternative Approaches** Other alternatives for testing function call performance could include: * Using `Function()` constructor, which creates a new global function object. * Utilizing `native` functions like `Math.sin()` or `Date.now()`, which are optimized for performance. * Implementing custom microbenchmarks using assembly language or other low-level languages. Keep in mind that the choice of alternative approaches depends on the specific use case and requirements.
Related benchmarks
Noop vs new arrow function call
Comments
Confirm delete:
Do you really want to delete benchmark?