Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Function property assignment vs setPrototypeOf
(version: 0)
Comparing performance of:
Few Property Assignments vs Many Property Assignments vs Small Prototype vs Large Prototype
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function XSmall() { const result = () => {}; result.fn1 = () => {}; result.fn2 = () => {}; return result; } function XSmallTest() { const r = XSmall(); r(); r.fn1(); r.fn2(); } function XBig() { const result = () => {}; result.fn1 = () => {}; result.fn2 = () => {}; result.fn3 = () => {}; result.fn4 = () => {}; result.fn5 = () => {}; result.fn6 = () => {}; result.fn7 = () => {}; result.fn8 = () => {}; result.fn9 = () => {}; result.fn10 = () => {}; result.fn11 = () => {}; result.fn12 = () => {}; result.fn13 = () => {}; result.fn14 = () => {}; result.fn15 = () => {}; result.fn16 = () => {}; result.fn17 = () => {}; result.fn18 = () => {}; result.fn19 = () => {}; result.fn20 = () => {}; result.fn21 = () => {}; result.fn22 = () => {}; result.fn23 = () => {}; result.fn24 = () => {}; result.fn25 = () => {}; result.fn26 = () => {}; result.fn27 = () => {}; result.fn28 = () => {}; result.fn29 = () => {}; result.fn30 = () => {}; result.fn31 = () => {}; result.fn32 = () => {}; result.fn33 = () => {}; result.fn34 = () => {}; result.fn35 = () => {}; result.fn36 = () => {}; result.fn37 = () => {}; result.fn38 = () => {}; result.fn39 = () => {}; result.fn40 = () => {}; return result; } function XBigTest() { const r = XBig(); r(); r.fn1(); r.fn2(); } const YSmallPrototype = Object.create({ fn1: () => {}, fn2: () => {}, }); function YSmall() { const result = () => {}; Object.setPrototypeOf(result, YSmallPrototype); return result; } function YSmallTest() { const r = YSmall(); r(); r.fn1(); r.fn2(); } const YBigPrototype = Object.create({ fn1: () => {}, fn2: () => {}, fn3: () => {}, fn4: () => {}, fn5: () => {}, fn6: () => {}, fn7: () => {}, fn8: () => {}, fn9: () => {}, fn10: () => {}, fn11: () => {}, fn12: () => {}, fn13: () => {}, fn14: () => {}, fn15: () => {}, fn16: () => {}, fn17: () => {}, fn18: () => {}, fn19: () => {}, fn20: () => {}, fn21: () => {}, fn22: () => {}, fn23: () => {}, fn24: () => {}, fn25: () => {}, fn26: () => {}, fn27: () => {}, fn28: () => {}, fn29: () => {}, fn30: () => {}, fn31: () => {}, fn32: () => {}, fn33: () => {}, fn34: () => {}, fn35: () => {}, fn36: () => {}, fn37: () => {}, fn38: () => {}, fn39: () => {}, fn40: () => {}, }); function YBig() { const result = () => {}; Object.setPrototypeOf(result, YBigPrototype); return result; } function YBigTest() { const r = YBig(); r(); r.fn1(); r.fn2(); }
Tests:
Few Property Assignments
XSmallTest()
Many Property Assignments
XBigTest()
Small Prototype
YSmallTest()
Large Prototype
YBigTest()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Few Property Assignments
Many Property Assignments
Small Prototype
Large Prototype
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and explain what's being tested. **Benchmark Definition** The benchmark is defined by four test cases: 1. `XSmallTest()`: This test case calls the function returned by `XSmallTest()` with few property assignments. 2. `XBigTest()`: This test case calls the function returned by `XBigTest()` with many property assignments. 3. `YSmallTest()`: This test case calls the function returned by `YSmallTest()` with a small prototype. 4. `YBigTest()`: This test case calls the function returned by `YBigTest()` with a large prototype. **Individual Test Cases** Each test case has two pieces of information: 1. `Benchmark Definition`: The actual code that defines the test case. 2. `Test Name`: A human-readable name for the test case. **What's Being Tested** The benchmark is testing the performance of JavaScript functions with varying numbers of property assignments. Specifically, it's measuring how fast these functions can execute and return results. **Two Approaches: Property Assignment and Prototype** There are two approaches being tested: 1. **Few Property Assignments**: This test case has a small number of property assignments. 2. **Many Property Assignments**: This test case has a large number of property assignments. These tests are likely measuring the overhead of assigning properties to an object, including the time it takes to create and initialize objects with many properties. 3. **Small Prototype**: This test case uses a small prototype (i.e., a small object that serves as the prototype for other objects). 4. **Large Prototype**: This test case uses a large prototype (i.e., a large object that serves as the prototype for other objects). These tests are likely measuring the overhead of using prototypes, including the time it takes to create and initialize objects with many properties. **Browser Results** The latest benchmark results show performance data from Chrome 104 on various platforms: * `Few Property Assignments`: The browser executes this test case approximately 12 million times per second. * `Small Prototype`: The browser executes this test case approximately 5.3 million times per second. * `Large Prototype`: The browser executes this test case approximately 5.2 million times per second. * `Many Property Assignments`: The browser executes this test case approximately 39 million times per second. Overall, the benchmark is providing a comparison of performance across different test cases with varying numbers of property assignments and prototype sizes.
Related benchmarks:
Class vs object: direct call vs bind vs apply
class vs function constructor vs object literal vs __proto__ vs Object.create vs Object.setPrototypeOf
Measuring impact of closures
"this" property vs. closure upvalue
Comments
Confirm delete:
Do you really want to delete benchmark?