Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Improve benchmark script CLI options

Chocobozzz1087427616d2
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
index 8811f0f458..eaad5db640 100644
--- a/.github/workflows/benchmark.yml
+++ b/.github/workflows/benchmark.yml
@@ -71,7 +71,7 @@ jobs:
- name: Run benchmark
run: |
- node dist/scripts/benchmark.js benchmark.json
+ node dist/scripts/benchmark.js -o benchmark.json
- name: Display result
run: |
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index 3c3c666a18..c9486eb371 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[] = []
diff --git a/support/doc/development/monitoring.md b/support/doc/development/monitoring.md
index 8b637e0791..9dcc2d563c 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
To benchmark the REST API and save result in `benchmark.json`:
```
-$ node dist/scripts/benchmark.js benchmark.json
+$ node dist/scripts/benchmark.js -o benchmark.json
+```
+
+You can also grep on a specific test:
+
+```
+$ node dist/scripts/benchmark.js --grep homepage
```