Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
prototype_test_01
(version: 0)
Comparing performance of:
pockets vs head
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
pockets
let head = { glasses: 1 }; let table = { __proto__: head, pen: 3 }; let bed = { __proto__: table, sheet: 1, pillow: 2 }; let pockets = { __proto__: bed, money: 2000 }; pockets.glasses
head
let head = { glasses: 1 }; let table = { __proto__: head, pen: 3 }; let bed = { __proto__: table, sheet: 1, pillow: 2 }; let pockets = { __proto__: bed, money: 2000 }; head.glasses
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
pockets
head
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser/OS:
Chrome 125 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
pockets
520453.8 Ops/sec
head
681879.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and test cases for you. **Benchmark Definition** The benchmark definition is a JSON object that represents the JavaScript code to be executed. It's written in a concise format, using bracket notation to access properties of objects. Here's a breakdown: * The first line `let head = { ... };` creates an object `head` with a single property `glasses` set to 1. * The second line creates another object `table`, which inherits the `__proto__` property from `head` and adds its own property `pen` set to 3. This means `table` has the same properties as `head` plus the additional property `pen`. * Similarly, `bed` is created with the same inheritance pattern, but with an additional property `sheet` set to 1 and `pillow` set to 2. * Finally, `pockets` is created, inheriting from `bed`, with an additional property `money` set to 2000. **Test Case** The test case is a JSON array containing two individual benchmarks. Each benchmark has the following properties: * `Benchmark Definition`: The actual JavaScript code to be executed. * `Test Name`: A short name for the benchmark. In this case, there are two tests: "head" and "pockets". These tests exercise different parts of the inheritance chain defined in the Benchmark Definition. **Options Compared** The test cases compare the performance of accessing properties on objects using prototype chaining (i.e., `head.glasses`) versus creating separate objects with the desired properties (e.g., `let pockets = { ... };`). **Pros and Cons** * **Prototype Chaining (e.g., `head.glasses`)**: + Pros: Compact code, potentially faster lookup times due to caching. + Cons: Can lead to slower execution if the property is not present on the prototype chain, as it will cause a loop to be executed. * **Creating Separate Objects (e.g., `let pockets = { ... };`)**: + Pros: Guarantees that the property is present and can avoid potential loops in case of a missing property. + Cons: More verbose code, potentially slower lookup times due to cache misses. **Library** There are no explicit libraries mentioned in the Benchmark Definition. However, the use of `__proto__` suggests that the benchmark assumes the JavaScript engine supports prototype inheritance. **Special JS Feature or Syntax** No special features or syntax are used in this benchmark. The code is written in standard ECMAScript 5+ syntax. **Other Alternatives** If you wanted to write a similar benchmark, you could consider using other approaches: * Use `Object.create()` instead of `__proto__` for prototype inheritance. * Use a loop to create multiple objects with the same properties and compare their performance. * Test the impact of `let` declarations on variable scope and cache behavior. Keep in mind that these alternatives might not accurately represent the original benchmark, but they could provide additional insights into different aspects of JavaScript performance.
Related benchmarks:
Classes vs Prototype
for-in versus object.keys with prototype
Test checking of literal object types
Test checking of literal object types - v2
javascript new vs Object.create 2
Comments
Confirm delete:
Do you really want to delete benchmark?