Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ES6 Class vs Prototype vs Object Literal (modified)
(version: 1)
Test the speed and memory usage using 3 different techniques for constructing class objects.
Comparing performance of:
ES6 Class vs Function Prototype vs Object Literal
Created:
one year ago
by:
Guest
Jump to the latest result
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);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
ES6 Class
Function Prototype
Object Literal
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
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/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
ES6 Class
724398.0 Ops/sec
Function Prototype
709090.9 Ops/sec
Object Literal
67524656.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 Class vs Prototype with longer chain vs Object Literal
ES6 Class vs Prototype vs Object Literal vs Object & Functions [rW@B8]
ES6 Class vs Prototype vs Object Literal vs Function vs Function with object destructuring
ES6 Class vs Prototype vs Object Literal (fixed)
ES6 Class vs Prototype vs Object Literal vs ES6 Class extends vs ES6 Class extends twice
Comments
Confirm delete:
Do you really want to delete benchmark?