@node-minify/benchmark
v10.4.0
Published
Benchmark tool for @node-minify compressors
Downloads
284
Maintainers
Readme
benchmark
benchmark is a tool for node-minify to compare compressor performance.
It allows you to benchmark different compressors and compare their compression ratio, speed, and output size.
Installation
npm install @node-minify/benchmarkUsage
Programmatic API
import { benchmark } from '@node-minify/benchmark';
const results = await benchmark({
input: 'src/app.js',
compressors: ['terser', 'esbuild', 'swc', 'oxc'],
iterations: 3,
includeGzip: true
});
console.log(results.summary.recommended); // Best balance of speed and compressionCLI
# Basic usage
node-minify benchmark src/app.js
# Compare specific compressors
node-minify benchmark src/app.js --compressors terser,esbuild,swc,oxc
# Custom compressors (npm packages or local files)
node-minify benchmark src/app.js --compressors terser,./my-compressor.js,my-custom-pkg
# With options
node-minify benchmark src/app.js -c terser,esbuild -n 3 --gzip -t js
# Output as JSON
node-minify benchmark src/app.js -c terser,esbuild -f json
# Output as Markdown
node-minify benchmark src/app.js -c terser,esbuild -f markdownOptions
| Option | CLI Flag | Description | Default |
|--------|----------|-------------|---------|
| input | <input> | File(s) to benchmark | Required |
| compressors | -c, --compressors | Comma-separated list of compressors | terser,esbuild,swc,oxc |
| iterations | -n, --iterations | Number of iterations | 1 |
| format | -f, --format | Output format: console, json, markdown | console |
| output | -o, --output | Output file path | stdout |
| includeGzip | --gzip | Include gzip size in results | false |
| type | -t, --type | File type: js, css, html | auto-detect |
Output Formats
Console (default)
🔍 Benchmarking: src/app.js (45.2 KB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Compressor Size Reduction Time Status
──────────────────────────────────────────────────────
terser 11.8 KB 73.9% 234ms OK
esbuild 12.3 KB 72.8% 45ms OK
swc 12.1 KB 73.2% 67ms OK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🏆 Best compression: terser
⚡ Fastest: esbuild
💡 Recommended: esbuildJSON
{
"timestamp": "2026-01-02T10:30:00Z",
"files": [{
"file": "src/app.js",
"originalSizeBytes": 46284,
"results": [
{ "compressor": "terser", "sizeBytes": 12083, "reductionPercent": 73.9, "timeMs": 234 },
{ "compressor": "esbuild", "sizeBytes": 12595, "reductionPercent": 72.8, "timeMs": 45 }
]
}],
"summary": {
"bestCompression": "terser",
"bestPerformance": "esbuild",
"recommended": "esbuild"
}
}Markdown
# Benchmark Results
**File:** src/app.js (45.2 KB)
**Date:** 2026-01-02T10:30:00Z
| Compressor | Size | Reduction | Time |
|------------|------|-----------|------|
| terser | 11.8 KB | 73.9% | 234ms |
| esbuild | 12.3 KB | 72.8% | 45ms |Documentation
Visit https://node-minify.2clics.net/benchmark for full documentation
