Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
es6 vs prototype vs module class
(version: 1)
Comparing performance of:
Es6 Class vs Prototype vs Module
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
Es6 Class
class Es6Point { constructor(x, y) { this.x = x; this.y = y; } add(point) { return new Es6Point(this.x + point.x, this.y + point.y); } sub(point) { return new Es6Point(this.x - point.x, this.y - point.y); } } const p1 = new Es6Point(10, 10); const p2 = new Es6Point(10, -10); const sum = p1.add(p2); const dif = p1.sub(p2);
Prototype
function ProtoPoint(x, y) { this.x = x; this.y = y; } ProtoPoint.prototype.add = function(point) { return new ProtoPoint(this.x + point.x, this.y + point.y); } ProtoPoint.prototype.sub = function(point) { return new ProtoPoint(this.x - point.x, this.y - point.y); } const p1 = new ProtoPoint(10, 10); const p2 = new ProtoPoint(10, -10); const sum = p1.add(p2); const dif = p1.sub(p2);
Module
const ModulePoint = (x, y) => ({ add: point => ModulePoint(x + point.x, y + point.y), sub: point => ModulePoint(x - point.x, y - point.y) }) const p1 = ModulePoint(10, 10) const p2 = ModulePoint(10, -10) const sum = p1.add(p2) const dif = p1.sub(p2)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Es6 Class
Prototype
Module
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser/OS:
Firefox 136 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Es6 Class
1096965.1 Ops/sec
Prototype
1220574.6 Ops/sec
Module
82222896.0 Ops/sec
Related benchmarks:
ES6 Class vs Prototype vs Object Literal
ES6 Class vs Prototype vs Object Literal vs Object & Functions
ES6 Class vs Prototype vs Object Literal vs Object & Functions 2
ES6 Class vs Prototype vs Object Literal n moar
es6 vs prototype class
ES6 Class vs Prototype with longer chain vs Object Literal
ES6 Class vs Prototype vs Object Literal (fixed)
ES6 Class vs Prototype vs Object Literal vs ES6 Class extends vs ES6 Class extends twice
ES6 Class vs Prototype vs Object Literal (modified)
Comments
Confirm delete:
Do you really want to delete benchmark?