Skip to content

Commit 70dc811

Browse files
committed
chore: update bench
1 parent 35aaf15 commit 70dc811

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

test/bench/impl.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ export function createInstances() {
1111
// "rou3-release-find-all",
1212
// createRouter(rou3Release as unknown as typeof rou3Src, true),
1313
// ],
14-
["maximum", createFastestRouter()],
15-
] as const;
14+
process.argv.includes("--max")
15+
? ["maximum", createFastestRouter()]
16+
: undefined,
17+
].filter(Boolean) as [string, (method: string, path: string) => any][];
1618
}
1719

1820
export function createRouter(rou3: typeof rou3Src, withAll: boolean = false) {

test/bench/index.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ import { createInstances } from "./impl";
55
const instances = createInstances();
66

77
const fullTests = process.argv.includes("--full");
8-
const noMaxTests = process.argv.includes("--no-max");
98

109
describe("param routes", () => {
1110
const nonStaticRequests = requests.filter((r) => r.data.includes(":"));
1211
for (const [name, _find] of instances) {
13-
if (noMaxTests && name === "maximum") {
14-
continue;
15-
}
1612
bench(name, () => {
1713
for (const request of nonStaticRequests) {
1814
_find(request.method, request.path);
@@ -24,9 +20,6 @@ describe("param routes", () => {
2420
if (fullTests) {
2521
describe("param and static routes", () => {
2622
for (const [name, _find] of instances) {
27-
if (noMaxTests && name === "maximum") {
28-
continue;
29-
}
3023
bench(name, () => {
3124
for (const request of requests) {
3225
_find(request.method, request.path);
@@ -38,9 +31,6 @@ if (fullTests) {
3831
for (const request of requests) {
3932
describe(`[${request.method}] ${request.path}`, () => {
4033
for (const [name, _find] of instances) {
41-
if (noMaxTests && name === "maximum") {
42-
continue;
43-
}
4434
bench(name, () => {
4535
_find(request.method, request.path);
4636
});
@@ -51,6 +41,8 @@ if (fullTests) {
5141

5242
await run();
5343

54-
if (!fullTests) {
55-
console.log("\nRun with --full to run all tests");
56-
}
44+
console.log(`
45+
Tips:
46+
- Run with --full to run all tests
47+
- Run with --max to compare with maximum possible performance
48+
`);

0 commit comments

Comments
 (0)