@jianghe/slate-dev-benchmark
Advanced tools
| /*! | ||
| * slate-dev-benchmark.js v0.0.6-2 | ||
| * (c) 2019-2020 Jiang He | ||
| * Released under the MIT License. | ||
| */ | ||
| 'use strict'; | ||
| var { | ||
| Repository, | ||
| repo | ||
| } = require('./Repository'); | ||
| var { | ||
| Suite | ||
| } = require('./Suite'); | ||
| var { | ||
| Bench | ||
| } = require('./Bench'); | ||
| module.exports = { | ||
| Repository, | ||
| Suite, | ||
| Bench, | ||
| repo | ||
| }; | ||
| //# sourceMappingURL=slate-dev-benchmark.js.map |
| {"version":3,"file":"slate-dev-benchmark.js","sources":["../src/index.js"],"sourcesContent":["const { Repository, repo } = require('./Repository');\nconst { Suite } = require('./Suite');\nconst { Bench } = require('./Bench');\n\nmodule.exports = {\n Repository, Suite, Bench, repo,\n};\n"],"names":["Repository","repo","require","Suite","Bench","module","exports"],"mappings":";;;;;;;AAAA,IAAM;AAAEA,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAAuBC,OAAO,CAAC,cAAD,CAApC;;AACA,IAAM;AAAEC,EAAAA;AAAF,IAAYD,OAAO,CAAC,SAAD,CAAzB;;AACA,IAAM;AAAEE,EAAAA;AAAF,IAAYF,OAAO,CAAC,SAAD,CAAzB;;AAEAG,MAAM,CAACC,OAAP,GAAiB;AACfN,EAAAA,UADe;AACHG,EAAAA,KADG;AACIC,EAAAA,KADJ;AACWH,EAAAA;AADX,CAAjB"} |
| /*! | ||
| * slate-dev-benchmark.js v0.0.6-2 | ||
| * (c) 2019-2020 Jiang He | ||
| * Released under the MIT License. | ||
| */ | ||
| (function (factory) { | ||
| typeof define === 'function' && define.amd ? define(factory) : | ||
| factory(); | ||
| }((function () { 'use strict'; | ||
| var _require = require('./Repository'), | ||
| Repository = _require.Repository, | ||
| repo = _require.repo; | ||
| var _require2 = require('./Suite'), | ||
| Suite = _require2.Suite; | ||
| var _require3 = require('./Bench'), | ||
| Bench = _require3.Bench; | ||
| module.exports = { | ||
| Repository: Repository, | ||
| Suite: Suite, | ||
| Bench: Bench, | ||
| repo: repo | ||
| }; | ||
| }))); |
| /*! | ||
| * slate-dev-benchmark.js v0.0.6-2 | ||
| * (c) 2019-2020 Jiang He | ||
| * Released under the MIT License. | ||
| */ | ||
| !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e=require("./Repository"),i=e.Repository,o=e.repo,r=require("./Suite").Suite,t=require("./Bench").Bench;module.exports={Repository:i,Suite:r,Bench:t,repo:o}})); |
| /*! | ||
| * slate-dev-benchmark.js v0.0.6-2 | ||
| * (c) 2019-2020 Jiang He | ||
| * Released under the MIT License. | ||
| */ | ||
| var { | ||
| Repository, | ||
| repo | ||
| } = require('./Repository'); | ||
| var { | ||
| Suite | ||
| } = require('./Suite'); | ||
| var { | ||
| Bench | ||
| } = require('./Bench'); | ||
| module.exports = { | ||
| Repository, | ||
| Suite, | ||
| Bench, | ||
| repo | ||
| }; | ||
| //# sourceMappingURL=slate-dev-benchmark.js.map |
| {"version":3,"file":"slate-dev-benchmark.js","sources":["../src/index.js"],"sourcesContent":["const { Repository, repo } = require('./Repository');\nconst { Suite } = require('./Suite');\nconst { Bench } = require('./Bench');\n\nmodule.exports = {\n Repository, Suite, Bench, repo,\n};\n"],"names":["Repository","repo","require","Suite","Bench","module","exports"],"mappings":";;;;;AAAA,IAAM;AAAEA,EAAAA,UAAF;AAAcC,EAAAA;AAAd,IAAuBC,OAAO,CAAC,cAAD,CAApC;;AACA,IAAM;AAAEC,EAAAA;AAAF,IAAYD,OAAO,CAAC,SAAD,CAAzB;;AACA,IAAM;AAAEE,EAAAA;AAAF,IAAYF,OAAO,CAAC,SAAD,CAAzB;;AAEAG,MAAM,CAACC,OAAP,GAAiB;AACfN,EAAAA,UADe;AACHG,EAAAA,KADG;AACIC,EAAAA,KADJ;AACWH,EAAAA;AADX,CAAjB"} |
+6
-6
| { | ||
| "name": "@jianghe/slate-dev-benchmark", | ||
| "packageName": "slate-dev-benchmark", | ||
| "description": "INTERNAL: A development-only benchmark tool for Slate's core.", | ||
| "version": "0.0.6-2", | ||
| "version": "0.0.6-3", | ||
| "license": "MIT", | ||
| "main": "src/index.js", | ||
| "main": "esm/slate-dev-benchmark.js", | ||
| "esm": "esm/slate-dev-benchmark.js", | ||
| "cjs": "cjs/slate-dev-benchmark.js", | ||
| "umd": "dist/slate-dev-benchmark.js", | ||
| "umdMin": "dist/slate-dev-benchmark.min.js", | ||
| "private": false, | ||
@@ -19,6 +22,3 @@ "repository": { | ||
| "mocha": "^2.5.3" | ||
| }, | ||
| "scripts": { | ||
| "clean": "rm -rf ./dist ./lib ./node_modules" | ||
| } | ||
| } |
+80
-86
| /* global Promise */ | ||
| const { BenchType } = require('./types') | ||
| const { makeOptions } = require('./makeOptions') | ||
| const { Timer } = require('./Timer') | ||
| const { logger } = require('./logger') | ||
| const { BenchType } = require('./types'); | ||
| const { makeOptions } = require('./makeOptions'); | ||
| const { Timer } = require('./Timer'); | ||
| const { logger } = require('./logger'); | ||
@@ -12,3 +12,3 @@ const errorReport = { | ||
| all: NaN, | ||
| } | ||
| }; | ||
@@ -28,9 +28,9 @@ /** | ||
| constructor(suite, name, options = {}) { | ||
| this.name = name | ||
| this.options = makeOptions({ ...suite.options, ...options }) | ||
| this.isFinished = false | ||
| this.inputter = () => undefined | ||
| this.runner = () => {} | ||
| this.report = { ...errorReport } | ||
| suite.addBench(this) | ||
| this.name = name; | ||
| this.options = makeOptions({ ...suite.options, ...options }); | ||
| this.isFinished = false; | ||
| this.inputter = () => undefined; | ||
| this.runner = () => {}; | ||
| this.report = { ...errorReport }; | ||
| suite.addBench(this); | ||
| } | ||
@@ -45,3 +45,3 @@ | ||
| isBench(obj) { | ||
| return obj && obj[BenchType] | ||
| return obj && obj[BenchType]; | ||
| } | ||
@@ -57,12 +57,12 @@ | ||
| if (Array.isArray(inputter)) { | ||
| this.inputter = index => inputter[index % inputter.length] | ||
| return | ||
| this.inputter = (index) => inputter[index % inputter.length]; | ||
| return; | ||
| } | ||
| if (typeof inputter === 'function') { | ||
| this.inputter = inputter | ||
| return | ||
| this.inputter = inputter; | ||
| return; | ||
| } | ||
| this.inputter = () => inputter | ||
| this.inputter = () => inputter; | ||
| } | ||
@@ -77,3 +77,3 @@ | ||
| run(runner) { | ||
| this.runner = runner | ||
| this.runner = runner; | ||
| } | ||
@@ -90,16 +90,18 @@ | ||
| async compose(times, initial) { | ||
| times = Math.floor(times) | ||
| const isAsync = this.options.async | ||
| const { runner, inputter } = this | ||
| times = Math.floor(times); | ||
| const isAsync = this.options.async; | ||
| const { runner, inputter } = this; | ||
| const { maxTime } = this.options | ||
| let seq = Number.isFinite(this.options.maxTries) ? 1 : NaN | ||
| let nextCheckIndex = seq | ||
| const hrStart = process.hrtime() | ||
| const { maxTime } = this.options; | ||
| let seq = Number.isFinite(this.options.maxTries) ? 1 : NaN; | ||
| let nextCheckIndex = seq; | ||
| const hrStart = process.hrtime(); | ||
| if (global.gc) { | ||
| global.gc() | ||
| global.gc(); | ||
| } | ||
| const report = { user: 0, system: 0, all: 0, hr: 0, cycles: 0 } | ||
| const report = { | ||
| user: 0, system: 0, all: 0, hr: 0, cycles: 0, | ||
| }; | ||
@@ -111,14 +113,14 @@ for ( | ||
| ) { | ||
| const tries = Math.min(times - initialIndex, this.options.allocationTries) | ||
| const thisTryReport = await runBundleTasks.call(this, tries, initialIndex) | ||
| const tries = Math.min(times - initialIndex, this.options.allocationTries); | ||
| const thisTryReport = await runBundleTasks.call(this, tries, initialIndex); | ||
| if (global.gc) { | ||
| global.gc() | ||
| global.gc(); | ||
| } | ||
| for (const key in report) { | ||
| report[key] += thisTryReport[key] | ||
| report[key] += thisTryReport[key]; | ||
| } | ||
| } | ||
| return report | ||
| return report; | ||
@@ -134,12 +136,10 @@ /** | ||
| function runBundleTasks(tries, initialIndex) { | ||
| const inputs = Array.from({ length: tries }).map(index => | ||
| inputter(index + initialIndex) | ||
| ) | ||
| const timer = new Timer() | ||
| timer.start() | ||
| return runFrom(0).then(cycles => { | ||
| timer.end() | ||
| const { elapsed } = timer | ||
| return { ...elapsed, cycles } | ||
| }) | ||
| const inputs = Array.from({ length: tries }).map((index) => inputter(index + initialIndex)); | ||
| const timer = new Timer(); | ||
| timer.start(); | ||
| return runFrom(0).then((cycles) => { | ||
| timer.end(); | ||
| const { elapsed } = timer; | ||
| return { ...elapsed, cycles }; | ||
| }); | ||
@@ -153,28 +153,24 @@ /** | ||
| function runFrom(index) { | ||
| if (index === tries) return Promise.resolve(tries) | ||
| if (index === tries) return Promise.resolve(tries); | ||
| if (index === nextCheckIndex) { | ||
| const hrEnd = process.hrtime(hrStart) | ||
| const elapsed = hrEnd[0] * 1e3 + hrEnd[1] / 1e6 | ||
| const hrEnd = process.hrtime(hrStart); | ||
| const elapsed = hrEnd[0] * 1e3 + hrEnd[1] / 1e6; | ||
| if (elapsed > maxTime) { | ||
| return Promise.resolve(index) | ||
| } else { | ||
| if (elapsed < maxTime / 20) { | ||
| seq *= 2 | ||
| } | ||
| return Promise.resolve(index); | ||
| } | ||
| if (elapsed < maxTime / 20) { | ||
| seq *= 2; | ||
| } | ||
| nextCheckIndex = seq + nextCheckIndex | ||
| } | ||
| nextCheckIndex = seq + nextCheckIndex; | ||
| } | ||
| if (!isAsync) { | ||
| const inputVar = inputs[index] | ||
| runner(inputVar) | ||
| return runFrom(index + 1) | ||
| } else { | ||
| return Promise.resolve(runner(inputs[index])).then(() => | ||
| runFrom(index + 1) | ||
| ) | ||
| const inputVar = inputs[index]; | ||
| runner(inputVar); | ||
| return runFrom(index + 1); | ||
| } | ||
| return Promise.resolve(runner(inputs[index])).then(() => runFrom(index + 1)); | ||
| } | ||
@@ -190,32 +186,30 @@ } | ||
| makeRun() { | ||
| if (this.isFinished) return true | ||
| logger(this) | ||
| const { options } = this | ||
| const { minTries, maxTime, maxTries } = options | ||
| if (this.isFinished) return true; | ||
| logger(this); | ||
| const { options } = this; | ||
| const { minTries, maxTime, maxTries } = options; | ||
| let { minTime } = options | ||
| if (minTime > maxTime) minTime = maxTime | ||
| let { minTime } = options; | ||
| if (minTime > maxTime) minTime = maxTime; | ||
| return this.compose(minTries, 0) | ||
| .then(report => { | ||
| if (this.options.mode === 'static') return report | ||
| const { all } = report | ||
| if (all > minTime) return report | ||
| const times = (minTime / all - 1) * minTries | ||
| .then((report) => { | ||
| if (this.options.mode === 'static') return report; | ||
| const { all } = report; | ||
| if (all > minTime) return report; | ||
| const times = (minTime / all - 1) * minTries; | ||
| return this.compose(Math.min(times, maxTries), minTries).then( | ||
| newReport => { | ||
| return mergeResults(report, newReport) | ||
| } | ||
| ) | ||
| (newReport) => mergeResults(report, newReport), | ||
| ); | ||
| }) | ||
| .then(report => { | ||
| this.report = report | ||
| this.isFinished = true | ||
| logger(this) | ||
| return true | ||
| }) | ||
| .then((report) => { | ||
| this.report = report; | ||
| this.isFinished = true; | ||
| logger(this); | ||
| return true; | ||
| }); | ||
| } | ||
| } | ||
| Bench.prototype[BenchType] = true | ||
| Bench.prototype[BenchType] = true; | ||
@@ -229,10 +223,10 @@ /* | ||
| function mergeResults(res1, res2) { | ||
| const result = {} | ||
| const result = {}; | ||
| for (const key in res1) { | ||
| result[key] = res1[key] + res2[key] | ||
| result[key] = res1[key] + res2[key]; | ||
| } | ||
| return result | ||
| return result; | ||
| } | ||
| module.exports = { Bench } | ||
| module.exports = { Bench }; |
+8
-8
| /* global Promise */ | ||
| const { errorLog } = require('./logger') | ||
| const { errorLog } = require('./logger'); | ||
@@ -11,13 +11,13 @@ /** | ||
| function compose(list, name = 'makeRun') { | ||
| return dispatch(0) | ||
| return dispatch(0); | ||
| function dispatch(index) { | ||
| if (index === list.length) return Promise.resolve(true) | ||
| const node = list[index] | ||
| return new Promise(resolve => resolve(node[name]())) | ||
| .catch(err => errorLog(err)) | ||
| .then(() => dispatch(index + 1)) | ||
| if (index === list.length) return Promise.resolve(true); | ||
| const node = list[index]; | ||
| return new Promise((resolve) => resolve(node[name]())) | ||
| .catch((err) => errorLog(err)) | ||
| .then(() => dispatch(index + 1)); | ||
| } | ||
| } | ||
| module.exports = { compose } | ||
| module.exports = { compose }; |
+6
-4
@@ -1,5 +0,7 @@ | ||
| const { Repository, repo } = require('./Repository') | ||
| const { Suite } = require('./Suite') | ||
| const { Bench } = require('./Bench') | ||
| const { Repository, repo } = require('./Repository'); | ||
| const { Suite } = require('./Suite'); | ||
| const { Bench } = require('./Bench'); | ||
| module.exports = { Repository, Suite, Bench, repo } | ||
| module.exports = { | ||
| Repository, Suite, Bench, repo, | ||
| }; |
+18
-19
@@ -7,6 +7,5 @@ /* eslint-disable no-console */ | ||
| const IS_TEST = | ||
| typeof process !== 'undefined' && | ||
| process.env && | ||
| process.env.BABEL_ENV === 'test' | ||
| const IS_TEST = typeof process !== 'undefined' | ||
| && process.env | ||
| && process.env.BABEL_ENV === 'test'; | ||
@@ -22,5 +21,5 @@ /** | ||
| function log(message, ...args) { | ||
| if (IS_TEST) return | ||
| if (IS_TEST) return; | ||
| return console.log(message, ...args) | ||
| return console.log(message, ...args); | ||
| } | ||
@@ -33,3 +32,3 @@ | ||
| function errorLog(message, ...args) { | ||
| console.error(message, ...args) | ||
| console.error(message, ...args); | ||
| } | ||
@@ -42,10 +41,10 @@ | ||
| function logger(obj) { | ||
| const prefix = ' ' | ||
| const prefix = ' '; | ||
| if (obj.isRepository) { | ||
| return log(`Repository ${obj.name} is running`) | ||
| return log(`Repository ${obj.name} is running`); | ||
| } | ||
| if (obj.isSuite) { | ||
| return log(`${prefix}- Suite ${obj.name} is running`) | ||
| return log(`${prefix}- Suite ${obj.name} is running`); | ||
| } | ||
@@ -55,7 +54,7 @@ | ||
| if (!obj.isFinished) { | ||
| return log(`${prefix + prefix}- Bench ${obj.name} is running`) | ||
| return log(`${prefix + prefix}- Bench ${obj.name} is running`); | ||
| } | ||
| const { report } = obj | ||
| const { cycles } = report | ||
| const { report } = obj; | ||
| const { cycles } = report; | ||
@@ -65,3 +64,3 @@ const header = { | ||
| hr: 'real:', | ||
| } | ||
| }; | ||
@@ -72,10 +71,10 @@ for (const key of ['user', 'hr']) { | ||
| report[key] | ||
| } ms; ( ${cycles * 1000 / report[key]} ops/sec)` | ||
| ) | ||
| } ms; ( ${cycles * 1000 / report[key]} ops/sec)`, | ||
| ); | ||
| } | ||
| return log(`${prefix + prefix + prefix}cycles: ${cycles}`) | ||
| return log(`${prefix + prefix + prefix}cycles: ${cycles}`); | ||
| } | ||
| return log(obj) | ||
| return log(obj); | ||
| } | ||
| module.exports = { logger, errorLog, log } | ||
| module.exports = { logger, errorLog, log }; |
@@ -9,3 +9,3 @@ const defaultOptions = { | ||
| mode: 'adaptive', | ||
| } | ||
| }; | ||
@@ -26,17 +26,17 @@ /** | ||
| function makeOptions(options) { | ||
| const result = { ...defaultOptions, ...options } | ||
| const result = { ...defaultOptions, ...options }; | ||
| for (const key in defaultOptions) { | ||
| const shallType = typeof defaultOptions[key] | ||
| const inputType = typeof result[key] | ||
| const shallType = typeof defaultOptions[key]; | ||
| const inputType = typeof result[key]; | ||
| if (shallType !== inputType) { | ||
| throw TypeError( | ||
| `Wrong Input in Config Suite, options[${key}] should be ${shallType}, but the input type is ${inputType}` | ||
| ) | ||
| `Wrong Input in Config Suite, options[${key}] should be ${shallType}, but the input type is ${inputType}`, | ||
| ); | ||
| } | ||
| } | ||
| return result | ||
| return result; | ||
| } | ||
| module.exports = { makeOptions } | ||
| module.exports = { makeOptions }; |
+21
-21
| /* global Promise */ | ||
| const { RepositoryType } = require('./types') | ||
| const { logger } = require('./logger') | ||
| const { compose } = require('./compose') | ||
| const { RepositoryType } = require('./types'); | ||
| const { logger } = require('./logger'); | ||
| const { compose } = require('./compose'); | ||
@@ -17,6 +17,6 @@ /** | ||
| constructor(name = 'default') { | ||
| this.name = name | ||
| this.suites = [] | ||
| this.report = {} | ||
| this.isFinished = false | ||
| this.name = name; | ||
| this.suites = []; | ||
| this.report = {}; | ||
| this.isFinished = false; | ||
| } | ||
@@ -31,3 +31,3 @@ | ||
| isRepository(obj) { | ||
| return obj && obj[RepositoryType] | ||
| return obj && obj[RepositoryType]; | ||
| } | ||
@@ -42,4 +42,4 @@ | ||
| addSuite(suite) { | ||
| this.isFinished = false | ||
| this.suites.push(suite) | ||
| this.isFinished = false; | ||
| this.suites.push(suite); | ||
| } | ||
@@ -53,18 +53,18 @@ | ||
| run() { | ||
| if (this.isFinished) return Promise.resolve(this.report) | ||
| logger(this) | ||
| if (this.isFinished) return Promise.resolve(this.report); | ||
| logger(this); | ||
| return compose(this.suites).then(() => { | ||
| this.isFinished = true | ||
| const report = {} | ||
| this.isFinished = true; | ||
| const report = {}; | ||
| for (const suite of this.suites) { | ||
| report[suite.name] = suite.report | ||
| report[suite.name] = suite.report; | ||
| } | ||
| this.report = report | ||
| return report | ||
| }) | ||
| this.report = report; | ||
| return report; | ||
| }); | ||
| } | ||
| } | ||
| Repository.prototype[RepositoryType] = true | ||
| Repository.prototype[RepositoryType] = true; | ||
@@ -75,4 +75,4 @@ /** | ||
| const repo = new Repository() | ||
| const repo = new Repository(); | ||
| module.exports = { Repository, repo } | ||
| module.exports = { Repository, repo }; |
+27
-27
| /* global Promise */ | ||
| const { repo } = require('./Repository.js') | ||
| const { SuiteType } = require('./types') | ||
| const { logger } = require('./logger') | ||
| const { compose } = require('./compose') | ||
| const { makeOptions } = require('./makeOptions') | ||
| const { repo } = require('./Repository.js'); | ||
| const { SuiteType } = require('./types'); | ||
| const { logger } = require('./logger'); | ||
| const { compose } = require('./compose'); | ||
| const { makeOptions } = require('./makeOptions'); | ||
@@ -22,18 +22,18 @@ /** | ||
| constructor(name, options = {}) { | ||
| const { repository = repo } = options | ||
| const { repository = repo } = options; | ||
| if (repository[name]) { | ||
| throw Error(`The suite name ${name} has benn occupied in repository`) | ||
| throw Error(`The suite name ${name} has benn occupied in repository`); | ||
| } | ||
| if (typeof name !== 'string') { | ||
| throw Error(`The suite name must be a string`) | ||
| throw Error('The suite name must be a string'); | ||
| } | ||
| this.name = name | ||
| this.options = makeOptions(options) | ||
| this.isFinished = false | ||
| this.benches = [] | ||
| this.report = {} | ||
| repository.addSuite(this) | ||
| this.name = name; | ||
| this.options = makeOptions(options); | ||
| this.isFinished = false; | ||
| this.benches = []; | ||
| this.report = {}; | ||
| repository.addSuite(this); | ||
| } | ||
@@ -48,3 +48,3 @@ | ||
| isSuite(obj) { | ||
| return obj && obj[SuiteType] | ||
| return obj && obj[SuiteType]; | ||
| } | ||
@@ -59,4 +59,4 @@ | ||
| addBench(bench) { | ||
| this.isFinished = false | ||
| this.benches.push(bench) | ||
| this.isFinished = false; | ||
| this.benches.push(bench); | ||
| } | ||
@@ -70,20 +70,20 @@ | ||
| makeRun() { | ||
| if (this.isFinished) return Promise.resolve(this.report) | ||
| logger(this) | ||
| if (this.isFinished) return Promise.resolve(this.report); | ||
| logger(this); | ||
| return compose(this.benches).then(() => { | ||
| this.isFinished = true | ||
| const report = {} | ||
| this.isFinished = true; | ||
| const report = {}; | ||
| for (const bench of this.benches) { | ||
| report[bench.name] = bench.report | ||
| report[bench.name] = bench.report; | ||
| } | ||
| this.report = report | ||
| return report | ||
| }) | ||
| this.report = report; | ||
| return report; | ||
| }); | ||
| } | ||
| } | ||
| Suite.prototype[SuiteType] = true | ||
| Suite.prototype[SuiteType] = true; | ||
| module.exports = { Suite } | ||
| module.exports = { Suite }; |
+20
-20
@@ -1,9 +0,9 @@ | ||
| const { TimerType } = require('./types') | ||
| const { TimerType } = require('./types'); | ||
| class Timer { | ||
| constructor() { | ||
| this.cpuStartTime = {} | ||
| this.hrStartTime = null | ||
| this.isStopped = false | ||
| this.elapsed = {} | ||
| this.cpuStartTime = {}; | ||
| this.hrStartTime = null; | ||
| this.isStopped = false; | ||
| this.elapsed = {}; | ||
| } | ||
@@ -17,3 +17,3 @@ | ||
| isTimer(obj) { | ||
| return obj && obj[TimerType] | ||
| return obj && obj[TimerType]; | ||
| } | ||
@@ -27,6 +27,6 @@ | ||
| start() { | ||
| this.isStopped = false | ||
| this.cpuStartTime = process.cpuUsage() | ||
| this.hrStartTime = process.hrtime() | ||
| this.elapsed = {} | ||
| this.isStopped = false; | ||
| this.cpuStartTime = process.cpuUsage(); | ||
| this.hrStartTime = process.hrtime(); | ||
| this.elapsed = {}; | ||
| } | ||
@@ -40,7 +40,7 @@ | ||
| end() { | ||
| if (this.isStopped) return this.elapsed | ||
| const cpuElapsed = process.cpuUsage(this.cpuStartTime) | ||
| const hrElapsed = process.hrtime(this.hrStartTime) | ||
| const { user, system } = cpuElapsed | ||
| const hr = hrElapsed[0] * 1000 + hrElapsed[1] / 1e6 | ||
| if (this.isStopped) return this.elapsed; | ||
| const cpuElapsed = process.cpuUsage(this.cpuStartTime); | ||
| const hrElapsed = process.hrtime(this.hrStartTime); | ||
| const { user, system } = cpuElapsed; | ||
| const hr = hrElapsed[0] * 1000 + hrElapsed[1] / 1e6; | ||
@@ -60,11 +60,11 @@ /** | ||
| hr, | ||
| } | ||
| }; | ||
| this.isStopped = true | ||
| return this.elapsed | ||
| this.isStopped = true; | ||
| return this.elapsed; | ||
| } | ||
| } | ||
| Timer.prototype[TimerType] = true | ||
| Timer.prototype[TimerType] = true; | ||
| module.exports = { Timer } | ||
| module.exports = { Timer }; |
+5
-5
@@ -1,5 +0,5 @@ | ||
| const RepositoryType = '@@__SLATE_REPOSITORY__@@' | ||
| const SuiteType = '@@__SLATE_SUITE__@@' | ||
| const BenchType = '@@__SLATE_BENCH__@@' | ||
| const TimerType = '@@__SLATE_BENCH_TIMER_@@' | ||
| const RepositoryType = '@@__SLATE_REPOSITORY__@@'; | ||
| const SuiteType = '@@__SLATE_SUITE__@@'; | ||
| const BenchType = '@@__SLATE_BENCH__@@'; | ||
| const TimerType = '@@__SLATE_BENCH_TIMER_@@'; | ||
@@ -11,2 +11,2 @@ module.exports = { | ||
| TimerType, | ||
| } | ||
| }; |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
21262
18.81%26
30%731
10.42%