Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ES6 Class vs Prototype vs Object Literal vs ES6 Class Extends
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
ES6 Class
3397123.0 Ops/sec
Function Prototype
2653530.5 Ops/sec
Object Literal
1663906.2 Ops/sec
Class extends
3004753.8 Ops/sec
Script Preparation code:
class ClassPoint { constructor(x, y) { this.x = x; this.y = y; } add(point) { this.x = this.x + point.x this.y = this.y + point.y } sub(point) { this.x = this.x - point.x this.y = this.y - point.y } } function FunctionPoint(x, y){ this.x = x; this.y = y; } FunctionPoint.prototype.add = function(point){ this.x = this.x + point.x this.y = this.y + point.y } FunctionPoint.prototype.sub = function(point){ this.x = this.x - point.x this.y = this.y - point.y } function ObjectPoint(x, y){ return { x, y, add:(point) => { this.x = this.x + point.x this.y = this.y + point.y }, sub:(point) => { this.x = this.x - point.x this.y = this.y - point.y }, } } class Base { constructor(x, y){ this.x = x; this.y = y; } } class ClassPoint2 extends Base { add(point){ this.x = this.x + point.x this.y = this.y + point.y } sub(point){ this.x = this.x - point.x this.y = this.y - point.y } }
Tests:
ES6 Class
var p1 = new ClassPoint(10, 10); var p2 = new ClassPoint(10, -10); var sum = p1.add(p2); var dif = p1.sub(p2);
Function Prototype
var p1 = new FunctionPoint(10, 10); var p2 = new FunctionPoint(10, -10); var sum = p1.add(p2); var dif = p1.sub(p2);
Object Literal
var p1 = ObjectPoint(10, 10); var p2 = ObjectPoint(10, -10); var sum = p1.add(p2); var dif = p1.sub(p2);
Class extends
var p1 = new ClassPoint2(10, 10); var p2 = new ClassPoint2(10, -10); var sum = p1.add(p2); var dif = p1.sub(p2);