diff options
-rw-r--r-- | .github/workflows/benchmark.yml | 2 | ||||
-rw-r--r-- | scripts/benchmark.ts | 17 | ||||
-rw-r--r-- | support/doc/development/monitoring.md | 8 |
3 files changed, 23 insertions, 4 deletions
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8811f0f45..eaad5db64 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml | |||
@@ -71,7 +71,7 @@ jobs: | |||
71 | 71 | ||
72 | - name: Run benchmark | 72 | - name: Run benchmark |
73 | run: | | 73 | run: | |
74 | node dist/scripts/benchmark.js benchmark.json | 74 | node dist/scripts/benchmark.js -o benchmark.json |
75 | 75 | ||
76 | - name: Display result | 76 | - name: Display result |
77 | run: | | 77 | run: | |
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 | ||
diff --git a/support/doc/development/monitoring.md b/support/doc/development/monitoring.md index 8b637e079..9dcc2d563 100644 --- a/support/doc/development/monitoring.md +++ b/support/doc/development/monitoring.md | |||
@@ -13,5 +13,11 @@ $ npm run build -- --analyze-bundle && npm run client-report | |||
13 | To benchmark the REST API and save result in `benchmark.json`: | 13 | To benchmark the REST API and save result in `benchmark.json`: |
14 | 14 | ||
15 | ``` | 15 | ``` |
16 | $ node dist/scripts/benchmark.js benchmark.json | 16 | $ node dist/scripts/benchmark.js -o benchmark.json |
17 | ``` | ||
18 | |||
19 | You can also grep on a specific test: | ||
20 | |||
21 | ``` | ||
22 | $ node dist/scripts/benchmark.js --grep homepage | ||
17 | ``` | 23 | ``` |