Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Performance difference between Object.defineProperty() and Object.defineProperties()
(version: 1)
Comparing performance of:
Object.defineProperty() vs Object.defineProperties()
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var testProps = {} for(let i = 1; i < 100; i++){ if(i%2){ testProps[`aa${i}`] = { value: i, writable: true, enumerable: false, configurable: false } } else { testProps[`aa${i}`] = { get(){ return this[`bb${i}`] }, set(nv){ this[`bb${i}`] = 2 * nv + 3; return true; }, enumerable: false, configurable: false } } }
Tests:
Object.defineProperty()
const testObj = {}, testProps_ = {...testProps}; for(let a in testProps_){ Object.defineProperty(testObj, a, testProps_[a]); }
Object.defineProperties()
const testObj = {}, testProps_ = {...testProps}; Object.defineProperties(testObj, testProps_)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object.defineProperty()
Object.defineProperties()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36
Browser/OS:
Chrome 144 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object.defineProperty()
49317.1 Ops/sec
Object.defineProperties()
33174.1 Ops/sec
Related benchmarks:
Data Properties vs. Accessor Properties vs. Getter / Setter Methods
Data Properties vs. Accessor Properties vs. Getter / Setter Methods 1
Data Properties vs. Accessor Properties vs. Getter / Setter Methods 2
getter vs properties
bind props test
Object Assignment vs DefineProperties
ES6 property (get/set) & getter/setter function vs direct access to object attribute (private and not) v2
Data Properties vs. Accessor Properties vs. Getter / Setter Methods v3
objct vs function vs class
Comments
Confirm delete:
Do you really want to delete benchmark?