Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Performance of new Error().stack
(version: 0)
Comparing performance of:
Stack vs Read
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
Stack
(new Error().stack)
Read
({ stack: 'foo' }.stack)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Stack
Read
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser/OS:
Chrome 125 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Stack
203107.7 Ops/sec
Read
174208160.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark definition and test cases to understand what's being tested. **Benchmark Definition:** The benchmark definition is simply an expression that generates a JavaScript object with a `stack` property. The two expressions are: 1. `(new Error().stack)` 2. `({ stack: 'foo' }.stack)` These expressions are used to create objects with a `stack` property, which represents the call stack of an error object. **Test Cases:** There are two test cases: 1. **"Stack"`** This test case is executed once per benchmark definition, and it simply measures the execution time of the expression `(new Error().stack)`. 2. **"Read"`** This test case is also executed once per benchmark definition, but it measures the execution time of the expression `({ stack: 'foo' }.stack)`. The difference between this test case and "Stack" is that it tries to access a property (`stack`) on an object (`{ ... }`). **Options Compared:** The two expressions being compared are: 1. **`new Error().stack`**: This expression creates a new error object with the call stack as its `stack` property. 2. **`({ stack: 'foo' }.stack)`**: This expression creates an object literal with a `stack` property, but it doesn't actually create an error object or access its call stack. **Pros and Cons of Each Approach:** 1. **`new Error().stack`**: * Pros: + Creates a real error object with the call stack. + Can be faster since it doesn't require parsing object literals. * Cons: + Can throw an error if not handled properly. 2. **`({ stack: 'foo' }.stack)`**: * Pros: + Does not throw errors. + Can be faster in some cases since it's a simple property access. * Cons: + Doesn't create a real error object, so the call stack is not actually accessed. **Library/ Syntax:** There are no libraries or special JavaScript features being tested here. The expressions are simply examples of creating objects with a `stack` property. **Special JS Feature/Syntax:** None mentioned. **Alternatives:** If you wanted to compare different approaches, some alternatives could be: * Creating an object literal with the `stack` property using a different syntax (e.g., `({ stack: 'foo' }).stack`). * Using a library or utility function to create the error object or access its call stack. * Comparing the execution times of different JavaScript engines or browsers. However, in this specific case, the two expressions are simple and don't involve any complex libraries or syntax.
Related benchmarks:
slice VS splice (clone) VS shift: who is the fastest to keep constant size
slice v splice chunking
iterating from a filled object VS iterating from a map
splice VS shift: who is the fastest to keep constant size
slice VS splice VS shift: who is the fastest to keep constant size (bulk test)
Comments
Confirm delete:
Do you really want to delete benchmark?