Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
void 0 and undefined in deep call stack - 3
(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){ let a = undefined; for(let i = 0; i < n; i++){ a === 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){ let a = undefined; for(let i = 0; i < n; i++){ a === 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
2023.7 Ops/sec
compare window.undefined and window.undefined
19.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** The provided benchmark measures the performance of JavaScript code in creating and running microbenchmarks on MeasureThat.net. The tests focus on two different scenarios: 1. **`void 0` vs `undefined`**: This test case compares the performance of using `void 0` (a more compact way to represent the value `undefined`) versus simply writing `undefined`. 2. **`window.undefined` vs `window(void 0)`**: The second test case examines the performance difference between accessing `undefined` directly and using the `window.` object with the `void 0` syntax. **Options Compared** The benchmark compares two different approaches: * Using `void 0` (or simply `undefined`) to represent an uninitialized value. * Accessing `undefined` directly (`window.undefined`). These options are compared in terms of execution speed, which is measured by the number of executions per second. **Pros and Cons** Here's a brief overview of the pros and cons of each approach: 1. **Using `void 0` (or simply `undefined`)** * Pros: * More compact syntax. * May be faster due to shorter string evaluation. * Cons: * Less readable code, as it uses a non-standard syntax. 2. **Accessing `undefined` directly (`window.undefined` or `window(void 0)`)** * Pros: * More readable code, as the intent is clearly conveyed using the `window.` object. * Cons: * Longer string evaluation time compared to `void 0`. **Library and Special JS Features** * **Library:** None. * **Special JS Feature/Syntax:** There are no special JavaScript features or syntax used in this benchmark. **Other Considerations** The benchmark assumes that the JavaScript engine being tested supports modern ECMAScript syntax, such as arrow functions and template literals. It also implies that the tests will be run on a platform with a relatively modern browser (in this case, Chrome 120). **Alternatives** If MeasureThat.net is not an option or if you want to create your own benchmarking tool, consider using: * **`Benchmark.js`**: A popular benchmarking library for Node.js and the browser. * **`js-benchmark`**: A lightweight benchmarking library for JavaScript. * **Google's Benchmark** (for Chrome only): A simple, high-performance benchmarking library developed by Google. Keep in mind that each of these alternatives has its own strengths and weaknesses, so be sure to evaluate their features and compatibility before choosing one.
Related benchmarks:
Return true vs empty body
accessing null vs undefined
void 0 vs undefined
Explicit call vs regular call
void 0 vs undefined vs variable containing undefined
Comments
Confirm delete:
Do you really want to delete benchmark?