This directory contains performance testing tools for Immer, allowing you to benchmark different versions of Immer and analyze CPU profiles to identify performance bottlenecks.
-
Install dependencies (in this directory):
yarn install
-
Build Immer first:
yarn build-immer
-
Build the benchmark bundle:
yarn build
Alternately, you can rebuild both Immer and the benchmarking script:
yarn build-with-latestTo run the performance benchmarks:
# Run basic benchmarks, with relative version speed comparisons
yarn benchmark
# Run the benchmarks, but also generate a CPU profile
yarn profileAfter running yarn profile, you'll get a .cpuprofile file. To analyze it:
# Analyze the most recent profile
yarn analyze-profile your-profile.cpuprofile- immutability-benchmarks.mjs: Main benchmark script comparing different Immer versions
- read-cpuprofile.js: Advanced CPU profile analyzer with sourcemap support
- rolldown.config.js: Bundler configuration that eliminates
process.envoverhead
The benchmarks compare:
- immer7-10: Historical Immer versions
- immer10Perf: Current development version (references
../dist) - vanilla: Pure JavaScript implementations for baseline comparison
- Sourcemap support: CPU profile analysis includes original function names
- Version-aware analysis: Breaks down performance by Immer version
- Production bundling: Uses Rolldown to eliminate development overhead