diff options
Diffstat (limited to 'fastify-busboy/benchmarks/common/commonBuilder.js')
-rw-r--r-- | fastify-busboy/benchmarks/common/commonBuilder.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fastify-busboy/benchmarks/common/commonBuilder.js b/fastify-busboy/benchmarks/common/commonBuilder.js new file mode 100644 index 0000000..b5707aa --- /dev/null +++ b/fastify-busboy/benchmarks/common/commonBuilder.js @@ -0,0 +1,46 @@ +'use strict' + +const { validateNotNil } = require('validation-utils') +const { BenchmarkBuilder } = require('photofinish') +const getopts = require('getopts') + +const options = getopts(process.argv.slice(1), { + alias: { + preset: 'p' + }, + default: {} +}) + +const PRESET = { + LOW: (builder) => { + return builder + .warmupCycles(1000) + .benchmarkCycles(1000) + }, + + MEDIUM: (builder) => { + return builder + .warmupCycles(1000) + .benchmarkCycles(2000) + }, + + HIGH: (builder) => { + return builder + .warmupCycles(1000) + .benchmarkCycles(10000) + } +} + +function getCommonBuilder () { + const presetId = options.preset || 'MEDIUM' + const preset = validateNotNil(PRESET[presetId.toUpperCase()], `Unknown preset: ${presetId}`) + + const builder = new BenchmarkBuilder() + preset(builder) + return builder + .benchmarkCycleSamples(50) +} + +module.exports = { + getCommonBuilder +} |