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'
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))
return status === 200 && body.startsWith('{"client":')
}
}
- ]
+ ].filter(t => {
+ if (!options.grep) return true
+
+ return t.title.includes(options.grep)
+ })
const finalResult: any[] = []
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
```