Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
object.assign vs new class extends
Performance difference of creating a class that extends P and creating a new instance of it vs doing object.assign(new P(), ...)
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
extend and create
585189.0 Ops/sec
object.assign
1227020.1 Ops/sec
Tests:
extend and create
class Vehicle { constructor(name){ this.name = name; } } class Ev extends Vehicle { constructor(name, charge){ super(name); this.charge = charge; } } const car = new Ev("leaf",90);
object.assign
class Vehicle { constructor(name){ this.name = name; } } const car = Object.assign(new Vehicle("leaf"),{ charge: 90 })