mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
add types to get-benchmarks, simple document explaining report contents
This commit is contained in:
@@ -3,7 +3,7 @@ import { spawn } from 'child_process';
|
||||
import { join } from 'path';
|
||||
|
||||
const wrk = (options: any) =>
|
||||
new Promise((resolve, reject) =>
|
||||
new Promise<WrkResults>((resolve, reject) =>
|
||||
wrkPkg(options, (err: any, result: any) =>
|
||||
err ? reject(err) : resolve(result),
|
||||
),
|
||||
@@ -15,7 +15,7 @@ const sleep = (time: number) =>
|
||||
const BENCHMARK_PATH = join(__dirname, '../../benchmarks');
|
||||
const LIBS = ['express', 'fastify', 'nest', 'nest-fastify'];
|
||||
|
||||
async function runBenchmarkOfLib(lib: string) {
|
||||
async function runBenchmarkOfLib(lib: string): Promise<WrkResults> {
|
||||
const libPath = join(BENCHMARK_PATH, `${lib}.js`);
|
||||
const process = spawn('node', [libPath], {
|
||||
detached: true,
|
||||
@@ -39,10 +39,30 @@ async function runBenchmarkOfLib(lib: string) {
|
||||
}
|
||||
|
||||
export async function getBenchmarks() {
|
||||
const results = {};
|
||||
const results: { [lib: string]: WrkResults } = {};
|
||||
for await (const lib of LIBS) {
|
||||
const result = await runBenchmarkOfLib(lib);
|
||||
results[lib] = result;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
interface WrkResults {
|
||||
transferPerSec: string;
|
||||
requestsPerSec: number;
|
||||
connectErrors: string;
|
||||
readErrors: string;
|
||||
writeErrors: string;
|
||||
timeoutErrors: string;
|
||||
requestsTotal: number;
|
||||
durationActual: string;
|
||||
transferTotal: string;
|
||||
latencyAvg: string;
|
||||
latencyStdev: string;
|
||||
latencyMax: string;
|
||||
latencyStdevPerc: number;
|
||||
rpsAvg: string;
|
||||
rpsStdev: string;
|
||||
rpsMax: string;
|
||||
rpsStdevPerc: number;
|
||||
}
|
||||
|
||||
20
tools/benchmarks/report-contents.md
Normal file
20
tools/benchmarks/report-contents.md
Normal file
@@ -0,0 +1,20 @@
|
||||
Short description (shown on main PR screen): Performance improved 0.13% on average.
|
||||
|
||||
Long description (after clicking details):
|
||||
|
||||
| | Req/sec | Trans/sec | Req/sec DIFF | Trans/sec DIFF | Req vs Express | Trans vs Fastify |
|
||||
| -------------- | ------- | --------- | ------------ | -------------- | -------------- | ---------------- |
|
||||
| NestJS-Express | 3.37MB | 16375.58 | +0.15% | +0.14% | 80.62% | 80.37% |
|
||||
| NestJS-Fastify | 4.78MB | 32728.51 | +0.12% | +0.12 | 64.76% | 64.25% |
|
||||
| Express | 4.18MB | 20374.59 | 0% | 0% | - | - |
|
||||
| Fastify | 7.38MB | 50938 | 0% | 0% | - | - |
|
||||
|
||||
## Explanations:
|
||||
|
||||
Short description: average of all diffs for NestJS-\* so: `(0.15 + 0.14 + 0.12 + 0.12) / 4`
|
||||
|
||||
Long description:
|
||||
|
||||
`req/sec DIFF` and `Trans/sec DIFF` is in comparison to the baseline on target branch (master).
|
||||
|
||||
Req vs express is calculated as perf compared to NOT using nestjs so: 80.62% = (3.37/4.18) \* 100%
|
||||
Reference in New Issue
Block a user