Tests:
  • Es6

    x
     
    class Es6Point {
        constructor(x, y) {
            this.x = x;
            this.y = y;
        }
        add(point) {
            return new Es6Point(this.x + point.x, this.y + point.y);
        }
        sub(point) {
            return new Es6Point(this.x - point.x, this.y - point.y);
        }
    }
    const p1 = new Es6Point(10, 10);
    const p2 = new Es6Point(10, -10);
    const sum = p1.add(p2);
    const dif = p1.sub(p2);
  • Prototype

     
    function ProtoPoint(x, y) {
        this.x = x;
        this.y = y;
    }
    ProtoPoint.prototype.add = function(point) {
        return new ProtoPoint(this.x + point.x, this.y + point.y);
    }
    ProtoPoint.prototype.sub = function(point) {
        return new ProtoPoint(this.x - point.x, this.y - point.y);
    }
    const p1 = new ProtoPoint(10, 10);
    const p2 = new ProtoPoint(10, -10);
    const sum = p1.add(p2);
    const dif = p1.sub(p2);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Es6
    Prototype

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 28 days ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135 on Windows
View result in a separate tab
Test name Executions per second
Es6 930983.5 Ops/sec
Prototype 960012.7 Ops/sec