README.md
This file
Path
perf-testing/README.md
71 lines · 1.7 KiB · Markdown
Last changed by
test: Implement a perf testing benchmarking system (#1163)Mark Eriksonbefore adoptionefa396d
History of this fileTake it
README.md
Immer Performance Testing
This directory contains performance testing tools for Immer, allowing you to benchmark different versions of Immer and analyze CPU profiles to identify performance bottlenecks.
Setup
-
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-latest
Usage
Running Benchmarks
To run the performance benchmarks:
# Run basic benchmarks, with relative version speed comparisons
yarn benchmark
# Run the benchmarks, but also generate a CPU profile
yarn profile
Analyzing CPU Profiles
After running yarn profile, you'll get a .cpuprofile file. To analyze it:
# Analyze the most recent profile
yarn analyze-profile your-profile.cpuprofile
What's Included
- 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
Benchmark Versions
The benchmarks compare:
- immer7-10: Historical Immer versions
- immer10Perf: Current development version (references
../dist) - vanilla: Pure JavaScript implementations for baseline comparison
Key Features
- 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