From 1087427616d21f5d82416ae8ee1d8802d88248ff Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Feb 2022 15:19:44 +0100 Subject: Improve benchmark script CLI options --- scripts/benchmark.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'scripts/benchmark.ts') diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts index 3c3c666a1..c9486eb37 100644 --- a/scripts/benchmark.ts +++ b/scripts/benchmark.ts @@ -1,4 +1,5 @@ import autocannon, { printResult } from 'autocannon' +import { program } from 'commander' import { writeJson } from 'fs-extra' import { Video, VideoPrivacy } from '@shared/models' import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' @@ -7,7 +8,15 @@ let server: PeerTubeServer let video: Video let threadId: number -const outfile = process.argv[2] +program + .option('-o, --outfile [outfile]', 'Outfile') + .option('--grep [string]', 'Filter tests you want to execute') + .description('Run API REST benchmark') + .parse(process.argv) + +const options = program.opts() + +const outfile = options.outfile run() .catch(err => console.error(err)) @@ -135,7 +144,11 @@ async function run () { return status === 200 && body.startsWith('{"client":') } } - ] + ].filter(t => { + if (!options.grep) return true + + return t.title.includes(options.grep) + }) const finalResult: any[] = [] -- cgit v1.2.3