Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,57 @@ const compilerCode = compileRouterToString(router, "findRoute");

<!--/automd -->

## Benchmarks

Performance benchmarks on **Apple M3 Max** with **Node.js 24** (using [mitata](https://github.com/evanwashere/mitata)):

### Realistic API Workloads

| Scenario | Compiled | Interpreter | Speedup |
|---|---|---|---|
| E-commerce API (108 routes, 33 requests) | **1.46 µs** | 3.67 µs | 2.5x |
| GitHub-like API (119 routes, 29 requests) | **886 ns** | 4.90 µs | 5.5x |
| findAllRoutes (overlapping, 6 requests) | **995 ns** | 1.58 µs | 1.6x |

### Route Type Latency (compiled, single lookup)

| Route Type | Avg Latency |
|---|---|
| Miss (not found) | **93 ns** |
| Static | **98 ns** |
| Wildcard | **253 ns** |
| Param (`:id`) | **528 ns** |

### Scaling

| Route Count | Compiled Lookup | Memory |
|---|---|---|
| 50 routes | 1.78 µs | ~31 KB |
| 200 routes | 8.53 µs | ~126 KB |
| 500 routes | 16.47 µs | ~322 KB |

### Build Performance

| Operation | 108 routes | 200 routes |
|---|---|---|
| `addRoute` | 78 µs | 143 µs |
| `compileRouter` | 58 µs | 106 µs |

### Running Benchmarks

```bash
# Existing micro-benchmarks
pnpm bench:node
pnpm bench:bun
pnpm bench:deno

# Realistic workload benchmarks
pnpm bench:realistic # Node.js (default: 6 groups)
pnpm bench:realistic -- --full # All groups (+ single latency, removeRoute, deep params)
pnpm bench:realistic:bun # Bun
pnpm bench:realistic:deno # Deno
```

## License

<!-- automd:contributors license=MIT author="pi0" -->
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"bench:bun": "bun ./test/bench",
"bench:deno": "deno run -A ./test/bench/index.ts",
"bench:node": "node --expose-gc --allow-natives-syntax --disable-warning=ExperimentalWarning --experimental-strip-types ./test/bench/index.ts",
"bench:realistic": "node --expose-gc --disable-warning=ExperimentalWarning --experimental-strip-types ./test/bench/realistic.ts",
"bench:realistic:bun": "bun ./test/bench/realistic.ts",
"bench:realistic:deno": "deno run -A ./test/bench/realistic.ts",
"build": "obuild",
"dev": "vitest",
"lint": "oxlint . && oxfmt --check src test",
Expand Down
Loading
Loading