1.0.7 • Published 7 months ago

@goodpie/js-build-benchmarker v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

JS Build Benchmarker

A command-line tool to benchmark and compare JavaScript build tools (webpack, esbuild, vite, rollup, etc.) by measuring build time, memory usage, and output size.

This is a tool that I have used for a while to explore different build tools for old projects, personal projects and legacy projects. Please use with other benchmarking tools.

npm version

Installation

Install globally:

npm install -g @goodpie/js-build-benchmarker
# or
bun install -g @goodpie/js-build-benchmarker

Usage

Initialize a benchmark configuration

js-build-benchmarker init

This interactive wizard will help you create a benchmark.config.json file with your build tools and configuration.

Run benchmarks

js-build-benchmarker run

Additional options:

  • -f, --file <path> - Specify a custom config file path
  • -i, --iterations <number> - Override number of iterations
  • --no-cache-clear - Disable cache clearing between runs

Configuration

The benchmark.config.json file contains your benchmark configuration:

{
  "iterations": 30,
  "clearCache": true,
  "tools": [
    {
      "name": "webpack",
      "command": "webpack --mode production",
      "outputDir": "dist/",
      "clearCacheDir": "node_modules/.cache/webpack"
    },
    {
      "name": "esbuild",
      "command": "bun esbuild --bundle --minify",
      "outputDir": "dist/",
      "clearCacheDir": ".esbuild-cache"
    }
  ]
}

Configuration Options

OptionDescription
iterationsNumber of benchmark runs to perform for each tool
clearCacheWhether to clear caches between runs
toolsArray of build tools to benchmark
cwdWorking directory for commands (optional)
globalEnvEnvironment variables for all tools (optional)

Tool Configuration

OptionDescription
nameTool name
commandBuild command to execute
outputDirDirectory with build output (for size measurement)
envTool-specific environment variables (optional)
clearCacheCommandCommand to clear cache (optional)
clearCacheDirDirectory to remove for cache clearing (optional)

Example Output

===== BENCHMARK SUMMARY =====

WEBPACK:
Build time (s): avg=5.42, min=4.98, max=5.87
Memory usage (MB): avg=245.32, min=220.15, max=265.87
Output Size (MB): avg=1.25, min=1.25, max=1.25

ESBUILD:
Build time (s): avg=0.32, min=0.28, max=0.38
Memory usage (MB): avg=95.42, min=90.18, max=102.33
Output Size (MB): avg=1.32, min=1.32, max=1.32

===== COMPARISONS =====

esbuild vs webpack:
Speed: esbuild is 16.94x faster
Memory: esbuild uses 0.39x less memory
Size: esbuild 0.95x less

Requirements

  • Node.js 20.x or later
  • Bun.js (recommended for better performance)

License

MIT

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago