@indutny/bencher
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -26,10 +26,40 @@ #!/usr/bin/env node | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const promises_1 = require("fs/promises"); | ||
const yargs_1 = __importDefault(require("yargs")); | ||
const helpers_1 = require("yargs/helpers"); | ||
async function main() { | ||
const modules = await Promise.all(process.argv.slice(2).map(async (file) => { | ||
const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) | ||
.alias('h', 'help') | ||
.option('d', { | ||
alias: 'duration', | ||
type: 'number', | ||
default: 5, | ||
describe: 'maximum duration in seconds per runner', | ||
}) | ||
.option('s', { | ||
alias: 'samples', | ||
type: 'number', | ||
default: 100, | ||
describe: 'number of samples to collect per runner', | ||
}) | ||
.option('w', { | ||
alias: 'sweep-width', | ||
type: 'number', | ||
default: 10, | ||
describe: 'width of iteration sweep', | ||
}) | ||
.option('warm-up-iterations', { | ||
type: 'number', | ||
default: 100, | ||
describe: 'number of warm up iterations', | ||
}).argv; | ||
const modules = await Promise.all(argv._.map(async (file) => { | ||
var _a; | ||
const path = await (0, promises_1.realpath)(file); | ||
const path = await (0, promises_1.realpath)(String(file)); | ||
const m = await (_a = path, Promise.resolve().then(() => __importStar(require(_a)))); | ||
const { duration = 5, sweepWidth = 10, samples = 100, warmUpIterations = 100, } = m.options ?? {}; | ||
const { duration = argv['duration'], sweepWidth = argv['sweepWidth'], samples = argv['samples'], warmUpIterations = argv['warmUpIterations'], } = m.options ?? {}; | ||
if (duration <= 0) { | ||
@@ -51,3 +81,3 @@ throw new Error(`${file}: options.duration must be positive`); | ||
return { | ||
name: m.name ?? file, | ||
name: m.name ?? String(file), | ||
options: { | ||
@@ -54,0 +84,0 @@ duration, |
{ | ||
"name": "@indutny/bencher", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Simple benchmarking tool", | ||
@@ -35,2 +35,3 @@ "bin": { | ||
"devDependencies": { | ||
"@types/yargs": "^17.0.17", | ||
"@typescript-eslint/eslint-plugin": "^5.47.0", | ||
@@ -42,3 +43,6 @@ "@typescript-eslint/parser": "^5.47.0", | ||
"typescript": "^4.9.4" | ||
}, | ||
"dependencies": { | ||
"yargs": "^17.6.2" | ||
} | ||
} |
@@ -28,3 +28,3 @@ # @indutny/bencher | ||
// benchmark.js | ||
export const name = 'benchmark name'; | ||
export const name = 'runner'; | ||
@@ -31,0 +31,0 @@ // Function to benchmark |
11049
210
1
7
+ Addedyargs@^17.6.2
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.1.2(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)