Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
class vs object create 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser:
Safari 18
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
5 months ago
Test name
Executions per second
class
445595936.0 Ops/sec
Object.create
187360928.0 Ops/sec
Script Preparation code:
class ObjClass { constructor(name, age) { this.name = name this.age = age } getName() { return this.name } getAge() { return this.age } } const objProto = { getName() { return this.name }, getAge() { return this.age } }
Tests:
class
const objClass = new ObjClass("john", 42) objClass.getName() objClass.getAge()
Object.create
let obj = Object.create(objProto) obj.name = "john" obj.age = 42 obj.getName() obj.getAge()