Skip to content

CLI Reference

Run benchmarks with powerful discovery and filtering options. The run command is the default and can be omitted.

Terminal window
# Run all benchmarks matching default pattern (./bench/**/*.bench.{js,mjs,cjs,ts})
modestbench
# Run all benchmarks in a directory (searches recursively)
modestbench benchmarks/
# Run specific files
modestbench benchmarks/critical.bench.js
# Run from multiple directories
modestbench src/perf/ tests/benchmarks/
# Mix files, directories, and glob patterns
modestbench file.bench.js benchmarks/ "tests/**/*.bench.ts"
# Explicit run command (optional)
modestbench run benchmarks/
  • JavaScript: .js, .mjs, .cjs
  • TypeScript: .ts, .mts, .cts

Specify a custom configuration file path.

Terminal window
modestbench --config ./custom-config.json

Number of samples to collect per benchmark task.

Terminal window
modestbench --iterations 5000

Higher values provide more accurate results but take longer to complete.

Time budget in milliseconds per benchmark task.

Terminal window
modestbench --time 10000

Control how benchmarks are limited. Options:

  • iterations - Stop after N samples (fast, predictable)
  • time - Run for T milliseconds (consistent time investment)
  • any - Stop when either threshold is reached (default when both specified)
  • all - Require both time AND iterations thresholds
Terminal window
# Explicit control
modestbench --iterations 500 --time 5000 --limit-by time
# Safety bounds (whichever comes first)
modestbench --iterations 1000 --time 10000 --limit-by any
# Statistical rigor (both required)
modestbench --iterations 100 --time 2000 --limit-by all

Smart Defaults:

  • Only --iterations → Uses iterations mode (fast)
  • Only --time → Uses time mode
  • Both specified → Uses any mode (whichever comes first)
  • Neither specified → Uses default iterations (100) with iterations mode

Number of warmup iterations before measurement begins.

Terminal window
modestbench --warmup 100

Helps stabilize JIT compilation for more consistent results.

Select the benchmark engine. Options: tinybench (default) or accurate.

Terminal window
# Use the accurate engine for high-precision measurements
node --allow-natives-syntax ./node_modules/.bin/modestbench --engine accurate
# Use tinybench engine (default)
modestbench --engine tinybench

Engine Differences:

  • tinybench (default): Fast, lightweight engine suitable for development and CI. Uses IQR-based outlier removal.
  • accurate: High-precision engine with V8 optimization guards to prevent JIT compiler interference. Requires --allow-natives-syntax flag. Recommended for production benchmarks and critical performance measurements.

See the Getting Started guide for detailed comparison.

Maximum time in milliseconds for a single task before timing out.

Terminal window
modestbench --timeout 60000

Default: 30000 (30 seconds)

Stop execution on first benchmark failure.

Terminal window
modestbench --bail

Useful in CI/CD to fail fast when performance regressions are detected.

Comma-separated list of reporters to use.

Terminal window
# Single reporter
modestbench --reporters json
# Multiple reporters simultaneously
modestbench --reporters human,json,csv

Available reporters:

  • human - Color-coded terminal output (default for TTY with colors)
  • simple - Plain text output (default for non-TTY environments)
  • json - Structured JSON data
  • csv - Tabular CSV format

Directory path for saving benchmark results and reports.

Terminal window
modestbench --reporters json,csv --output ./results

When specified:

  • JSON reporter writes to {output}/results.json
  • CSV reporter writes to {output}/results.csv
  • Human reporter still writes to stdout/stderr

Minimal output mode. Suppresses progress bars and non-essential messages.

Terminal window
modestbench --quiet

Detailed output mode with additional debugging information.

Terminal window
modestbench --verbose

Run only benchmarks with specific tags (OR logic - matches ANY).

Terminal window
# Single tag
modestbench --tags fast
# Multiple tags (matches ANY)
modestbench --tags string,array,algorithm

Tags cascade from file → suite → task levels. If a benchmark has ANY of the specified tags, it will run.

Exclude benchmarks with specific tags.

Terminal window
# Exclude one type
modestbench --exclude-tags slow
# Exclude multiple types
modestbench --exclude-tags experimental,unstable

Run benchmark files concurrently (experimental).

Terminal window
modestbench --concurrent
Terminal window
modestbench \
--config ./config.json \
--iterations 2000 \
--warmup 50 \
--reporters human,json,csv \
--output ./results \
--tags performance,algorithm \
--exclude-tags experimental \
--quiet \
benchmarks/

Initialize a project with configuration and example benchmarks.

Terminal window
# Interactive initialization
modestbench init
# Specify project type
modestbench init basic
modestbench init advanced
modestbench init library
# Specify config format
modestbench init --config-type typescript
modestbench init --config-type json
modestbench init --config-type yaml
modestbench init --config-type js
  • basic - Simple setup for small projects

    • 100 iterations
    • Human reporter
    • Minimal configuration
  • advanced - Feature-rich setup

    • 1000 iterations
    • Warmup enabled
    • Human + JSON reporters
    • Organized suite structure
  • library - Optimized for library performance testing

    • 5000 iterations
    • High warmup (100)
    • Human + JSON reporters
    • Comprehensive suite organization
  1. Generates a configuration file in your chosen format
  2. Creates an example benchmark file
  3. Appends .modestbench/ to .gitignore to exclude historical data

Manage benchmark history and compare results over time.

List recent benchmark runs.

Terminal window
modestbench history list

Show detailed results for a specific run.

Terminal window
modestbench history show run-2025-10-07-001

Compare two benchmark runs.

Terminal window
modestbench history compare run-2025-10-07-001 run-2025-10-07-002

Export historical data.

Terminal window
# Export to CSV
modestbench history export --format csv --output results.csv
# Export to JSON
modestbench history export --format json --output results.json

Clean old benchmark data.

Terminal window
# Clean runs older than 30 days
modestbench history clean --older-than 30d
# Keep only last 10 runs
modestbench history clean --keep 10
# Clean by size
modestbench history clean --max-size 100mb

These options work with all commands:

Show help information.

Terminal window
modestbench --help
modestbench --help # shows run command help (default command)
modestbench history --help

Show version number.

Terminal window
modestbench --version

modestbench respects several environment variables:

Enable debug mode with detailed logging.

Terminal window
DEBUG=1 modestbench

Shows full error stack traces and additional debugging information.

Automatically detected CI environment flag.

Terminal window
CI=true modestbench

When detected:

  • Captures CI provider information
  • Stores build details in results
  • May adjust defaults for CI-friendly output

Node.js environment mode. Stored in benchmark results for context.

Terminal window
NODE_ENV=production modestbench

Control color output in terminal.

Terminal window
# Force color output
FORCE_COLOR=1 modestbench
# Disable color output
NO_COLOR=1 modestbench

Command-line flags override configuration file settings:

modestbench.config.json
{
"iterations": 1000,
"reporters": ["human"]
}
Terminal window
# CLI flags take precedence
modestbench --iterations 5000 --reporters json
# Result: iterations=5000, reporters=["json"]

Priority order:

  1. Default values (lowest)
  2. Configuration file
  3. CLI flags (highest)
Terminal window
modestbench --iterations 10 --quiet
Terminal window
modestbench \
--iterations 5000 \
--warmup 100 \
--reporters human,json,csv \
--output ./results
Terminal window
modestbench \
--reporters json,csv \
--output ./benchmark-results \
--quiet \
--bail \
--tags critical
Terminal window
# Run current benchmarks
modestbench --reporters json --output ./current
# Compare with baseline
modestbench history compare baseline-run-id $(modestbench history list --format json | jq -r '.[0].id')