Script Preparation code:
x
 
class Point {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }
    add(point) {
        return new Point(this.x + point.x, this.y + point.y);
    }
    sub(point) {
        return new Point(this.x - point.x, this.y - point.y);
    }
}
var Point1 = Point;
function Point2(x, y) {
    this.x = x;
    this.y = y;
}
Point2.prototype.add = function(point) {
    return new Point2(this.x + point.x, this.y + point.y);
}
Point2.prototype.sub = function(point) {
    return new Point2(this.x - point.x, this.y - point.y);
}
function Point3(x, y) {
    return {
        x,
        y,
        add: (point) => Point3(this.x + point.x, this.y + point.y),
        sub: (point) => Point3(this.x - point.x, this.y - point.y)
    }
}
var add = (a, b) => (a.x + b.x, a.y + b.y)
var sub = (a, b) => (a.x - b.x, a.y - b.y)
Tests:
  • ES6 Class

     
    var p1 = new Point1(10, 10);
    var p2 = new Point1(10, -10);
    var sum = p1.add(p2);
    var dif = p1.sub(p2);
  • Function Prototype

     
    var p1 = new Point2(10, 10);
    var p2 = new Point2(10, -10);
    var sum = p1.add(p2);
    var dif = p1.sub(p2);
  • Object Literal

     
    var p1 = Point3(10, 10);
    var p2 = Point3(10, -10);
    var sum = p1.add(p2);
    var dif = p1.sub(p2);
  • Functional

     
    var p1 = {x:10, y:10};
    var p2 = {x:10, y:-10};
    var sum = add(p1, p2);
    var dif = sub(p1, p2);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    ES6 Class
    Function Prototype
    Object Literal
    Functional

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 months ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Chrome 133 on Windows
View result in a separate tab
Test name Executions per second
ES6 Class 171140640.0 Ops/sec
Function Prototype 217401216.0 Ops/sec
Object Literal 2575268.2 Ops/sec
Functional 238724688.0 Ops/sec