Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ES6 Class vs Prototype vs Object Literal (modified)
Test the speed and memory usage using 3 different techniques for constructing class objects.
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
ES6 Class
692266.6 Ops/sec
Function Prototype
747493.5 Ops/sec
Object Literal
72280016.0 Ops/sec
Tests:
ES6 Class
class Point { constructor(x, y){ this.x = x; this.y = y; } } function add(p1, p2) { return new Point(p1.x + p2.x, p1.y + p2.y); } function sub(p1, p2) { return new Point(p1.x - p2.x, p1.y - p2.y); } var p1 = new Point(10, 10); var p2 = new Point(10, -10); var sum = add(p1, p2); var dif = sub(p1, p2);
Function Prototype
function Point(x, y){ this.x = x; this.y = y; } function add(p1, p2) { return new Point(p1.x + p2.x, p1.y + p2.y); } function sub(p1, p2) { return new Point(p1.x - p2.x, p1.y - p2.y); } var p1 = new Point(10, 10); var p2 = new Point(10, -10); var sum = add(p1, p2); var dif = sub(p1, p2);
Object Literal
function add(p1, p2) { return Point(p1.x + p2.x, p1.y + p2.y); } function sub(p1, p2) { return Point(p1.x - p2.x, p1.y - p2.y); } function Point(x, y){ return { x, y, } } var p1 = Point(10, 10); var p2 = Point(10, -10); var sum = add(p1, p2); var dif = sub(p1, p2);