Test name | Executions per second |
---|---|
ES6 Class | 9497850.0 Ops/sec |
Function Prototype | 9330962.0 Ops/sec |
Object Literal | 7778546.0 Ops/sec |
Object 2 | 5129016.5 Ops/sec |
class PointC {
constructor(x, y){
this.x = x;
this.y = y;
}
add(value){
return this.x + this.y + value;
}
}
//---------------------------------------
function PointP(x, y){
this.x = x;
this.y = y;
}
PointP.prototype.add = function(value){
return this.x + this.y + value;
}
//---------------------------------------
function PointO(x, y){
return {
x,
y,
add: value => this.x + this.y + value
}
}
//---------------------------------------
var PointS = {
x: 10,
y: 10
}
var Add = (point, value) => point.x + point.y + value;
var p1C = new PointC(10, 10);
var p1P = new PointP(10, 10);
var p1O = new PointO(10, 10);
var sum = p1C.add(10000);
var sum = p1P.add(10000);
var sum = p1O.add(10000);
var sum = Add(PointS, 10000);