-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
178 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
docs/benchmarks/AMD Ryzen 9 7940HS w Radeon 780M Graphics.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Benchmark Report | ||
> - CPU: AMD Ryzen 9 7940HS w/ Radeon 780M Graphics | ||
> - RAM: 31 GB | ||
> - NodeJS Version: v20.10.0 | ||
> - Backend Server: 1 core / 1 thread | ||
> - Arguments: | ||
> - Count: 1,024 | ||
> - Threads: 4 | ||
> - Simultaneous: 32 | ||
> - Total Elapsed Time: 501 ms | ||
### Total | ||
Type | Count | Success | Mean. | Stdev. | Minimum | Maximum | ||
----|----|----|----|----|----|---- | ||
Total | 1,052 | 1,052 | 14.08 | 7.8 | 3 | 74 | ||
|
||
### Endpoints | ||
Type | Count | Success | Mean. | Stdev. | Minimum | Maximum | ||
----|----|----|----|----|----|---- | ||
GET /monitors/system | 563 | 563 | 14.12 | 7.78 | 3 | 71 | ||
GET /monitors/health | 489 | 489 | 14.04 | 7.83 | 4 | 74 | ||
|
||
### Failures | ||
Method | Path | Count | Success | ||
-------|------|-------|-------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { DynamicBenchmarker } from "@nestia/e2e"; | ||
import fs from "fs"; | ||
import os from "os"; | ||
|
||
import { MyBackend } from "../../src/MyBackend"; | ||
import { MyConfiguration } from "../../src/MyConfiguration"; | ||
import { MyGlobal } from "../../src/MyGlobal"; | ||
import { ArgumentParser } from "../../src/utils/ArgumentParser"; | ||
|
||
interface IOptions { | ||
include?: string[]; | ||
exclude?: string[]; | ||
count: number; | ||
threads: number; | ||
simultaneous: number; | ||
} | ||
|
||
const getOptions = () => | ||
ArgumentParser.parse<IOptions>(async (command, prompt, action) => { | ||
// command.option("--mode <string>", "target mode"); | ||
// command.option("--reset <true|false>", "reset local DB or not"); | ||
command.option("--include <string...>", "include feature files"); | ||
command.option("--exclude <string...>", "exclude feature files"); | ||
command.option("--count <number>", "number of requests to make"); | ||
command.option("--threads <number>", "number of threads to use"); | ||
command.option( | ||
"--simultaneous <number>", | ||
"number of simultaneous requests to make", | ||
); | ||
return action(async (options) => { | ||
// if (typeof options.reset === "string") | ||
// options.reset = options.reset === "true"; | ||
// options.mode ??= await prompt.select("mode")("Select mode")([ | ||
// "LOCAL", | ||
// "DEV", | ||
// "REAL", | ||
// ]); | ||
// options.reset ??= await prompt.boolean("reset")("Reset local DB"); | ||
options.count = Number( | ||
options.count ?? | ||
(await prompt.number("count")("Number of requests to make")), | ||
); | ||
options.threads = Number( | ||
options.threads ?? | ||
(await prompt.number("threads")("Number of threads to use")), | ||
); | ||
options.simultaneous = Number( | ||
options.simultaneous ?? | ||
(await prompt.number("simultaneous")( | ||
"Number of simultaneous requests to make", | ||
)), | ||
); | ||
return options as IOptions; | ||
}); | ||
}); | ||
|
||
const main = async (): Promise<void> => { | ||
// CONFIGURATIONS | ||
const options: IOptions = await getOptions(); | ||
MyGlobal.testing = true; | ||
|
||
// BACKEND SERVER | ||
const backend: MyBackend = new MyBackend(); | ||
await backend.open(); | ||
|
||
// DO BENCHMARK | ||
const report: DynamicBenchmarker.IReport = await DynamicBenchmarker.master({ | ||
count: options.count, | ||
threads: options.threads, | ||
simultaneous: options.simultaneous, | ||
filter: (func) => | ||
(!options.include?.length || | ||
(options.include ?? []).some((str) => func.includes(str))) && | ||
(!options.exclude?.length || | ||
(options.exclude ?? []).every((str) => !func.includes(str))), | ||
servant: `${__dirname}/servant.js`, | ||
}); | ||
|
||
// DOCUMENTATION | ||
try { | ||
await fs.promises.mkdir(`${MyConfiguration.ROOT}/docs/benchmarks`, { | ||
recursive: true, | ||
}); | ||
} catch {} | ||
await fs.promises.writeFile( | ||
`${MyConfiguration.ROOT}/docs/benchmarks/${os | ||
.cpus()[0] | ||
.model.trim() | ||
.split("\\") | ||
.join("") | ||
.split("/") | ||
.join("")}.md`, | ||
DynamicBenchmarker.markdown(report), | ||
"utf8", | ||
); | ||
|
||
// CLOSE | ||
await backend.close(); | ||
}; | ||
main().catch((exp) => { | ||
console.error(exp); | ||
process.exit(-1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DynamicBenchmarker } from "@nestia/e2e"; | ||
|
||
import { MyConfiguration } from "../../src/MyConfiguration"; | ||
|
||
DynamicBenchmarker.servant({ | ||
connection: { | ||
host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`, | ||
}, | ||
location: `${__dirname}/../features`, | ||
parameters: (connection) => [connection], | ||
prefix: "test_api_", | ||
}).catch((exp) => { | ||
console.error(exp); | ||
process.exit(-1); | ||
}); |