UNPKG

karma-benchmark

Version:

Run Benchmark.js over multiple Browsers, with CI compatible output

408 lines (359 loc) 13.1 kB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/karma-benchmark.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./node_modules/webpack/buildin/global.js": /*!***********************************!*\ !*** (webpack)/buildin/global.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || new Function("return this")(); } catch (e) { // This works if the window reference is available if (typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /***/ "./src/karma-benchmark.ts": /*!********************************!*\ !*** ./src/karma-benchmark.ts ***! \********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) { exports.__esModule = true; var process_benchmarks_1 = __webpack_require__(/*! ./process-benchmarks */ "./src/process-benchmarks.ts"); var provide_api_1 = __webpack_require__(/*! ./provide-api */ "./src/provide-api.ts"); var provide_dump_1 = __webpack_require__(/*! ./provide-dump */ "./src/provide-dump.ts"); var run_benchmarks_1 = __webpack_require__(/*! ./run-benchmarks */ "./src/run-benchmarks.ts"); var store = __webpack_require__(/*! ./store */ "./src/store.ts"); var wrapped_benchmark_1 = __webpack_require__(/*! ./wrapped-benchmark */ "./src/wrapped-benchmark.ts"); global.Benchmark = wrapped_benchmark_1.WrappedBenchmark; provide_api_1.provideApi(global); provide_dump_1.provideDump(global); global.__karma__.start = function () { run_benchmarks_1.runBenchmarks(global, process_benchmarks_1.processBenchmarks(store.getSuites())); }; /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js"))) /***/ }), /***/ "./src/process-benchmarks.ts": /*!***********************************!*\ !*** ./src/process-benchmarks.ts ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var lodash_1 = __webpack_require__(/*! lodash */ "lodash"); exports.processBenchmarks = function (suites) { var isFocused = function (_a) { var runAlone = _a.runAlone; return runAlone === true; }; var isFocusedSuite = function (suite) { return isFocused(suite) || lodash_1.some(suite, isFocused); }; var focusedSuites = suites.filter(isFocusedSuite); var focusBenchmarks = function (suite) { var focusedBenchmarks = suite.filter(isFocused); var removed = suite.length - focusedBenchmarks.length; var name = suite.name + " (" + removed + " benchmarks have been ignored)"; focusedBenchmarks.name = name; return focusedBenchmarks.length ? focusedBenchmarks : suite; }; return focusedSuites.length > 0 ? focusedSuites.map(focusBenchmarks) : suites; }; /***/ }), /***/ "./src/provide-api.ts": /*!****************************!*\ !*** ./src/provide-api.ts ***! \****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.provideApi = function (obj) { var addSuite = function (name, addBenchmarks, options, runAlone) { var suite = new obj.Benchmark.Suite(name, options); suite.runAlone = Boolean(runAlone); updateBenchmarkApi(obj, suite); addBenchmarks(); }; var focusSuite = function (name, addBenchmarks, options) { addSuite(name, addBenchmarks, options, true); }; var skipSuite = function () { /* noop */ }; obj.suite = addSuite; obj.suite.only = obj.ssuite = focusSuite; obj.suite.skip = obj.xsuite = skipSuite; }; var updateBenchmarkApi = function (obj, suite) { var addBenchmark = function (name, fn, options, runAlone) { suite.add(name, fn, options); var benchmark = suite[suite.length - 1]; benchmark.runAlone = Boolean(runAlone); }; var focusBenchmark = function (name, addBenchmarks, options) { addBenchmark(name, addBenchmarks, options, true); }; var skipBenchmark = function () { /* noop */ }; obj.benchmark = addBenchmark; obj.benchmark.only = obj.bbenchmark = focusBenchmark; obj.benchmark.skip = obj.xbenchmark = skipBenchmark; }; /***/ }), /***/ "./src/provide-dump.ts": /*!*****************************!*\ !*** ./src/provide-dump.ts ***! \*****************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.provideDump = function (obj) { obj.dump = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var ngMock = obj.angular && obj.angular.mock ? obj.angular.mock : null; obj.__karma__.info({ dump: args.map(function (value) { return (ngMock ? ngMock.dump(value) : value); }) }); }; }; /***/ }), /***/ "./src/run-benchmarks.ts": /*!*******************************!*\ !*** ./src/run-benchmarks.ts ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.runBenchmarks = function (_a, suites) { var __karma__ = _a.__karma__, __coverage__ = _a.__coverage__; var runNextBenchmark = function () { if (suites.length > 0) { runSuite(suites.shift()); } else { onComplete(); } }; var onComplete = function () { __karma__.complete({ coverage: __coverage__ }); }; var runSuite = function (suite) { var errors = []; suite .on('cycle', function (_a) { var target = _a.target; __karma__.result({ benchmark: { count: target.count, cycles: target.cycles, error: target.error, hz: target.hz, name: target.name, stats: target.stats, suite: suite.name }, description: suite.name + ": " + target.name, id: target.id, log: errors, skipped: false, success: errors.length === 0, suite: [], time: target.stats.mean * 1000 }); errors = []; }) .on('abort error', function (_a) { var target = _a.target; errors.push(target.error.toString()); }) .on('complete', runNextBenchmark) .run({ async: true }); }; runNextBenchmark(); }; /***/ }), /***/ "./src/store.ts": /*!**********************!*\ !*** ./src/store.ts ***! \**********************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var benchmarks = []; var suites = []; exports.addBenchmark = function (benchmark, hasSuite) { benchmark.hasSuite = Boolean(hasSuite); benchmarks.push(benchmark); return benchmark; }; exports.addSuite = function (suite) { suites.push(suite); return suite; }; exports.getSuites = function () { return suites; }; /***/ }), /***/ "./src/wrapped-benchmark.ts": /*!**********************************!*\ !*** ./src/wrapped-benchmark.ts ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var Benchmark = __webpack_require__(/*! benchmark */ "benchmark"); var store = __webpack_require__(/*! ./store */ "./src/store.ts"); var Suite = Benchmark.Suite; var construct = function (Instance, a, b, c) { if (c) { return new Instance(a, b, c); } if (b) { return new Instance(a, b); } if (a) { return new Instance(a); } return new Instance(); }; exports.WrappedBenchmark = function (name, fn, options) { var benchmark = construct(Benchmark, name, fn, options); return store.addBenchmark(benchmark, false); }; var WrappedSuite = function (name, options) { var suite = construct(Suite, name, options); suite.add = addBenchmark; store.addSuite(suite); return suite; }; function addBenchmark(name, fn, options) { var suite = Suite.prototype.add.call(this, name, fn, options); var benchmark = suite[suite.length - 1]; store.addBenchmark(benchmark, true); return suite; } exports.WrappedBenchmark.Suite = WrappedSuite; /***/ }), /***/ "benchmark": /*!****************************!*\ !*** external "Benchmark" ***! \****************************/ /*! no static exports found */ /***/ (function(module, exports) { module.exports = Benchmark; /***/ }), /***/ "lodash": /*!********************!*\ !*** external "_" ***! \********************/ /*! no static exports found */ /***/ (function(module, exports) { module.exports = _; /***/ }) /******/ });