Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
obj inheritance create assign setproto
(version: 2)
Comparing performance of:
setproto vs assign_create vs create vs proto vs factory vs assign
Created:
7 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
(function(){ function _base() { return { a:111,b:1,c:'2134124141', d:'werrqwer',e:'34234',fffffffff:'324234', gggggg:'99999',jadf:'adsfa',asdfasdf:'asdf',asdfasdf:'sadf', [Math.random()]:Math.random(), [Math.random()]:Math.random() } } (function(){ const base = _base() window.assign = function(x){ return Object.assign({[Math.random()+'x']:Math.random()+'x'+x},base) } })(); (function(){ const base = _base() window.setproto = function(x){ const z = Object.setPrototypeOf({ [Math.random()+'x']: Math.random()+'x'+x },base) return z } })(); (function(){ const base = _base() window.proto = function(x){ const z = { [Math.random()+'x']: Math.random()+'x'+x } z.__proto__ = base return z } })(); (function(){ const base = _base() window.create = function(x){ const p = Object.create(base) p[Math.random()+'x'] = Math.random()+'x'+x return p } })(); (function(){ const base = _base() window.assign_create = function(x){ return Object.assign(Object.create(base), { [Math.random()+'x']: Math.random()+'x'+x} ) } })(); (function(){ const base = _base() window.factory = function(x){ const o = _base() o[Math.random()+'x'] = Math.random()+'x'+x return o } })(); })()
Tests:
setproto
setproto('a')
assign_create
assign_create('b')
create
create('d')
proto
proto('e')
factory
factory('3')
assign
assign('4')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
setproto
assign_create
create
proto
factory
assign
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!
Related benchmarks:
Object.assign vs mutation assign
Object speard vs assign
Create object
Spread vs Object.assign (modify ) vs Object.assign (new)
Object.assign() vs spread operator (New object)
Comments
Confirm delete:
Do you really want to delete benchmark?