diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-28 15:19:44 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-02-28 15:19:44 +0100 |
commit | 1087427616d21f5d82416ae8ee1d8802d88248ff (patch) | |
tree | 59330e93ba857c2cc122370802a1848ded97d0d9 /scripts | |
parent | f7ac03ee94d9d32e26bd712e8dc05a6109f5e835 (diff) | |
download | PeerTube-1087427616d21f5d82416ae8ee1d8802d88248ff.tar.gz PeerTube-1087427616d21f5d82416ae8ee1d8802d88248ff.tar.zst PeerTube-1087427616d21f5d82416ae8ee1d8802d88248ff.zip |
Improve benchmark script CLI options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/benchmark.ts | 17 |
1 files changed, 15 insertions, 2 deletions
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 @@ | |||
1 | import autocannon, { printResult } from 'autocannon' | 1 | import autocannon, { printResult } from 'autocannon' |
2 | import { program } from 'commander' | ||
2 | import { writeJson } from 'fs-extra' | 3 | import { writeJson } from 'fs-extra' |
3 | import { Video, VideoPrivacy } from '@shared/models' | 4 | import { Video, VideoPrivacy } from '@shared/models' |
4 | import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' | 5 | import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' |
@@ -7,7 +8,15 @@ let server: PeerTubeServer | |||
7 | let video: Video | 8 | let video: Video |
8 | let threadId: number | 9 | let threadId: number |
9 | 10 | ||
10 | const outfile = process.argv[2] | 11 | program |
12 | .option('-o, --outfile [outfile]', 'Outfile') | ||
13 | .option('--grep [string]', 'Filter tests you want to execute') | ||
14 | .description('Run API REST benchmark') | ||
15 | .parse(process.argv) | ||
16 | |||
17 | const options = program.opts() | ||
18 | |||
19 | const outfile = options.outfile | ||
11 | 20 | ||
12 | run() | 21 | run() |
13 | .catch(err => console.error(err)) | 22 | .catch(err => console.error(err)) |
@@ -135,7 +144,11 @@ async function run () { | |||
135 | return status === 200 && body.startsWith('{"client":') | 144 | return status === 200 && body.startsWith('{"client":') |
136 | } | 145 | } |
137 | } | 146 | } |
138 | ] | 147 | ].filter(t => { |
148 | if (!options.grep) return true | ||
149 | |||
150 | return t.title.includes(options.grep) | ||
151 | }) | ||
139 | 152 | ||
140 | const finalResult: any[] = [] | 153 | const finalResult: any[] = [] |
141 | 154 | ||