Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
vector dot function vs prototype vs class
(version: 0)
Comparing performance of:
function vs prototype vs class
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
function
function Vector(x, y) { this.x = x; this.y = y; this.dot = function(other) { return this.x * other.x + this.y * other.y; } } let i = 1000; let a = new Vector(0.5, 0.3); let b = new Vector(0.21, 0.63); let c = 0; while(--i) { c += a.dot(b); } return c;
prototype
function Vector(x, y) { this.x = x; this.y = y; } Vector.prototype.dot = function(other) { return this.x * other.x + this.y * other.y; } let i = 1000; let a = new Vector(0.5, 0.3); let b = new Vector(0.21, 0.63); let c = 0; while(--i) { c += a.dot(b); } return c;
class
class Vector { constructor(x, y) { this.x = x; this.y = y; } dot(other) { return this.x * other.x + this.y * other.y; } } let i = 1000; let a = new Vector(0.5, 0.3); let b = new Vector(0.21, 0.63); let c = 0; while(--i) { c += a.dot(b); } return c;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
function
prototype
class
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
ES6 Class vs Prototype vs Object Literal v2
Instantiation via ES6 Class vs Prototype vs Object Literal
Scoped function vs Object Literal vs prototype vs external dependencies - v1
Comparison of classes vs prototypes vs object literals also including the inheritance
ES6 Class vs Prototype vs Object Literal vs Function vs Function with object destructuring
Comments
Confirm delete:
Do you really want to delete benchmark?