-
Notifications
You must be signed in to change notification settings - Fork 12
feat: configurable high-iteration benchmarks with env var overrides #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Zario Benchmark Results | ||
|
|
||
| Results from running `npm run bench:high` (500,000 iterations/sample, 8 samples, 20% warmup). | ||
|
|
||
| Environment: Node.js v24.14.1, `--expose-gc` | ||
|
|
||
| --- | ||
|
|
||
| ## Sync Logging | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Simple message (sync) | 500,000 | 100,000 | 11,552,893 | 11,509,206 | 11,626,194 | 87 | 43.28 | | ||
| | Message with metadata (sync) | 500,000 | 100,000 | 10,572,753 | 10,538,822 | 10,653,341 | 95 | 47.29 | | ||
| | Message with deep metadata (sync) | 500,000 | 100,000 | 6,687,858 | 6,655,676 | 6,698,615 | 150 | 74.76 | | ||
|
|
||
| ## Filtered Logs (Early Exit) | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Filtered debug log (level=error) | 500,000 | 100,000 | 1,008,217,655 | 993,001,783 | 1,724,197,386 | 1 | 0.50 | | ||
| | Filtered info log (level=error) | 500,000 | 100,000 | 1,005,689,767 | 930,771,268 | 1,597,270,584 | 1 | 0.50 | | ||
|
|
||
| ## JSON Formatting | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Simple JSON log | 500,000 | 100,000 | 11,568,692 | 11,557,255 | 11,661,240 | 86 | 43.22 | | ||
| | JSON log with metadata | 500,000 | 100,000 | 10,543,431 | 10,419,380 | 10,687,100 | 95 | 47.43 | | ||
|
|
||
| ## Async Logging | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Simple message (async enqueue) | 500,000 | 100,000 | 5,079,084 | 5,067,134 | 5,096,529 | 197 | 98.44 | | ||
| | Message with metadata (async enqueue) | 500,000 | 100,000 | 4,987,750 | 4,915,549 | 5,008,323 | 200 | 100.25 | | ||
|
|
||
| ## Formatter Direct | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Format text (with metadata) | 500,000 | 100,000 | 2,181,644 | 2,179,942 | 2,189,498 | 458 | 229.19 | | ||
| | Format text (simple) | 500,000 | 100,000 | 3,790,382 | 3,784,413 | 3,806,556 | 264 | 131.91 | | ||
| | Format JSON (with metadata) | 500,000 | 100,000 | 931,265 | 929,513 | 939,866 | 1,074 | 536.90 | | ||
| | Format JSON (simple fast path) | 500,000 | 100,000 | 1,390,686 | 1,388,912 | 1,406,143 | 719 | 359.54 | | ||
|
|
||
| ## Child Logger | ||
|
|
||
| | Benchmark | Iter/sample | Warmup | Median ops/sec | Mean ops/sec | P95 ops/sec | Median ns/op | Median total (ms) | | ||
| |---|---:|---:|---:|---:|---:|---:|---:| | ||
| | Child logger simple message | 500,000 | 100,000 | 10,453,676 | 10,445,592 | 10,480,180 | 96 | 47.83 | | ||
| | Child logger with metadata | 500,000 | 100,000 | 10,117,448 | 10,084,576 | 10,169,217 | 99 | 49.42 | | ||
|
|
||
| --- | ||
|
|
||
| ## Running the Benchmarks | ||
|
|
||
| ```sh | ||
| # Standard benchmark (50k–200k iterations/sample) | ||
| npm run bench | ||
|
|
||
| # High-iteration benchmark (500k iterations/sample, 8 samples) | ||
| npm run bench:high | ||
|
|
||
| # Custom iterations/samples via environment variables | ||
| ZARIO_BENCH_ITERATIONS=1000000 ZARIO_BENCH_SAMPLES=10 npm run bench | ||
| ``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ | |
| "dev": "tsup --watch", | ||
| "test": "jest", | ||
| "lint": "eslint src benchmarks --ext .ts --max-warnings=0", | ||
| "bench": "node --expose-gc --import tsx/esm benchmarks/logger.bench.ts", | ||
| "bench:high": "ZARIO_BENCH_ITERATIONS=500000 ZARIO_BENCH_SAMPLES=8 node --expose-gc --import tsx/esm benchmarks/logger.bench.ts", | ||
|
Comment on lines
+35
to
+36
|
||
| "prepublishOnly": "npm run build" | ||
| }, | ||
| "repository": { | ||
|
|
@@ -83,6 +85,7 @@ | |
| "jest": "^30.2.0", | ||
| "ts-jest": "^29.4.5", | ||
| "tsup": "^8.5.1", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.9.3", | ||
| "typescript-eslint": "^8.49.0" | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benchmark config reads iteration/sample counts directly via
Number(...)and only checks> 0. This allows non-integers (e.g.0.5),Infinity(e.g.1e309/Infinity), or very large values, which can lead to misleading metrics (division by non-integer) or effectively infinite loops/hangs. Consider parsing as an integer and validating withNumber.isFinite+Number.isInteger, and either clamping or throwing a clear error when invalid/out-of-range values are provided.