Script Preparation code:
x
 
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var barker = function barker(state) {
    return {
        bark: function bark() {
            return console.log("woof, I am " + state.name);
        }
    };
};
var driver = function driver(state) {
    return {
        drive: function drive() {
            return state.position = state.position + state.speed;
        }
    };
};
var robotDog = function robotDog(name) {
    var state = {
        name: name,
        speed: 100,
        position: 0
    };
    return Object.assign({}, barker(state), driver(state));
};
var Driver = function () {
    function Driver() {
        _classCallCheck(this, Driver);
    }
    _createClass(Driver, [{
        key: "drive",
        value: function drive() {
            console.log("I am driving");
        }
    }]);
    return Driver;
}();
var Barker = function (_Driver) {
    _inherits(Barker, _Driver);
    function Barker(name) {
        _classCallCheck(this, Barker);
        var _this = _possibleConstructorReturn(this, (Barker.__proto__ || Object.getPrototypeOf(Barker)).call(this));
        _this.name = name;
        return _this;
    }
    _createClass(Barker, [{
        key: "bark",
        value: function bark() {
            console.log("woof, I am " + this.name);
        }
    }]);
    return Barker;
}(Driver);
window.robotDog = robotDog;
window.Barker = Barker;
},{}]},{},[1])
Tests:
  • Instantiation

     
    var red = new Barker("red");
  • Composition

     
    var yellow = robotDog("yellow");
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Instantiation
    Composition

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.27
Chrome 105 on Windows
View result in a separate tab
Test name Executions per second
Instantiation 7235619.0 Ops/sec
Composition 2888534.0 Ops/sec