Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.assign vs defineProperties vs setPrototypeOf vs extends Function vs defineProperty
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
defineProperties
1.8M/s
defineProperty
1.7M/s
extends Function
1.2M/s
Object.assign
856K/s
setPrototypeOf
418K/s
View exact numbers
Test name
Executions per second
✓
defineProperties
1,787,984 Ops/sec
defineProperty
1,749,860 Ops/sec
extends Function
1,156,444 Ops/sec
Object.assign
856,100 Ops/sec
setPrototypeOf
417,894 Ops/sec
Tests:
Object.assign
let f = ()=>0 Object.assign(f, { _foo: null, get foo() {return this._foo}, set foo(_foo) {this._foo = _foo}, })
defineProperties
let f = ()=>0 Object.defineProperties(f, { foo: { value: null, writable: true } })
setPrototypeOf
let f = ()=>0 Object.setPrototypeOf(f, { ...Function.prototype, _foo: null, get foo() {return this._foo}, set foo(_foo) {this._foo = _foo}, })
extends Function
class F extends Function { constructor() { super('return 0') } _foo = null get foo() {return this._foo} set foo(_foo) {this._foo = _foo} }
defineProperty
let f = ()=>0 f._foo = null Object.defineProperty(f, 'foo', { get() { return this._foo }, set(_foo) { this._foo = _foo } })