Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
void 0 and undefined in deep call stack - 2
(version: 0)
Check performance degradation due to scope chain when undefined is called from deep stack
Comparing performance of:
compare window.undefined and void 0 vs compare window.undefined and window.undefined
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
compare window.undefined and void 0
function compare(n= 1e6){ for(let i = 0; i < n; i++){ undefined === void 0; } } function deep(num){ if (num === 0) { compare(); return; } else { deep(num-1); } } deep(10);
compare window.undefined and window.undefined
function compare(n= 1e6){ for(let i = 0; i < n; i++){ undefined === undefined; } } function deep(num){ if (num === 0) { compare(); return; } else { deep(num-1); } } deep(10);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
compare window.undefined and void 0
compare window.undefined and window.undefined
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/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
compare window.undefined and void 0
19.0 Ops/sec
compare window.undefined and window.undefined
9.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**What is being tested?** MeasureThat.net is testing the performance of JavaScript in two different scenarios: 1. **`undefined === void 0`**: This test case checks how the JavaScript engine performs when comparing `undefined` with `void 0`. The idea is to see if the engine uses an optimized path for this comparison, which might involve checking the type of the variables or using a specialized optimization. 2. **`window.undefined and window.undefined`**: In this test case, the engine is expected to compare two identical values: `window.undefined` (note the space between `w` and `i`) with itself. This test aims to measure how the engine handles self-comparisons, which can be a micro-optimization. **Options compared** The options being compared in these tests are: * Using `undefined === void 0` vs. using `window.undefined` * Self-comparison (`window.undefined and window.undefined`) vs. comparing with a different value **Pros and cons of each approach:** 1. **`undefined === void 0`**: * Pros: This comparison is more likely to be optimized by the engine, as it's a common use case. * Cons: It may not accurately measure performance in all scenarios where `void 0` is used differently (e.g., with `var`, `let`, or `const` declarations). 2. **Self-comparison (`window.undefined and window.undefined`)**: * Pros: This test can help identify performance issues specific to self-comparisons, which might not be caught by other tests. * Cons: The engine may use an optimized path for this comparison as well, making it harder to distinguish between the two tests. **Other considerations** When interpreting the results: * **Timing variability**: Execution times can vary due to factors like CPU frequency, memory pressure, or browser-specific optimizations. Take these variations into account when drawing conclusions about performance differences. * **JavaScript engine-specific behavior**: Different JavaScript engines (e.g., V8 for Chrome) may exhibit unique characteristics when executing these tests. **Library and special JS feature** No libraries are explicitly mentioned in the test cases provided. However, `void 0` is used instead of just `undefined`, which is a common convention to ensure consistency across environments. The use of `$` (dollar sign) in the benchmark definition is not present in these examples.
Related benchmarks:
Return true vs empty body
accessing null vs undefined
Explicit call vs regular call
Noop vs new arrow function calls
undefined comparison
Comments
Confirm delete:
Do you really want to delete benchmark?