Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
es6 vs prototype class
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
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Es6
541527.4 Ops/sec
Prototype
221335.3 Ops/sec
Tests:
Es6
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);