This project contains scripts and configuration to reproduce and measure performance degradation in SWC when using plugins.
generate-files.js— script to generate a large number of React component files in thesrc/directory for benchmarking.template.jsx— template for generated React components.src/— directory where test files are generated.swc-old/— SWC setup with an older version (1.3.95) and plugin configuration.swc-new/— SWC setup with a newer version (1.13.1) and plugin configuration.run_swc.sh— shell script to run SWC builds with different versions and plugin options.
To install all dependencies for both SWC versions, run:
npm run install:depsTo generate a large number of test files in the src/ directory (by default, 100,000 files):
npm run generate-filesThis will clear the src/ directory and populate it with generated React components for benchmarking.
You can run SWC builds with or without the plugin, and with the old or new SWC version. Use the following commands:
- Old SWC, without_plugin:
npm run build:old:without_plugin
- Old SWC, with_plugin:
npm run build:old:with_plugin
- New SWC, without_plugin:
npm run build:new:without_plugin
- New SWC, with_plugin:
npm run build:new:with_plugin
Each command will print the SWC version and the execution time for the build.
To run all benchmarks (all build variants, 3 times each, with summary and comparison), use:
./benchmark_all.shThis script will:
- Run all four build variants (old/new × with_plugin/without_plugin) three times each
- Print intermediate and average times for each variant
- Show how much slower with_plugin is compared to without_plugin
- Show how much faster or slower the new version is compared to the old (without_plugin)
- The
src/directory is generated and not tracked by git. - The
dist/andnode_modules/directories are also ignored by git. - You can adjust the number of generated files by editing the
FILES_TOTALconstant ingenerate-files.js.
Feel free to open issues or contribute improvements for more accurate benchmarking or additional scenarios.