run-bench
รัน benchmark tests เพื่อวัดประสิทธิภาพและเปรียบเทียบ performance
SKILL.mdrun-bench/SKILL.md
GitHubGoal
Run benchmark tests to measure code performance and compare performance between implementations
Scope
Use for measuring function performance, comparing different implementations, detecting performance regressions, and optimizing code based on benchmark results
Execute
Pre-Run: always run
/deep-reviewfirst —run-*skills must be reviewed/assessed before the main action, never skip; if findings are blockers, fix or report them before running (bench)
1. Setup Environment
Goal: Setup Environment
- Run
/run-installto install dependencies and benchmark libraries (e.g.vitest bench,tinybench) - Check that benchmark files exist in the project (e.g.
*.bench.ts,bench/directory) - Check the benchmark script in
package.json(e.g.bun run bench) - If baseline results exist, record them for comparison
2. Run Benchmarks
Goal: Run Benchmarks
- Run
bun run benchor the script defined inpackage.json - To run only specific benchmarks, provide a pattern (e.g.
bun run bench -- --grep "pattern") - Wait for the benchmarks to finish and record all results
- Run
/reportto format the results
3. Analyze Results
Goal: Analyze Results
- Review each benchmark's result and identify the slow and fast benchmarks
- Run
/deep-reviewperdeep-review-codebase-everything/SKILL.mdto analyze whether empirical growth matches theoretical complexity - Find benchmarks with high variance or outliers
- Identify potential optimizations for slow benchmarks
- If variance is high, re-run to confirm the results
4. Compare With Baseline
Goal: Compare With Baseline
- Compare the results with the baseline if one exists
- Identify regressions (slower) and improvements (faster)
- Record results and action items for optimization
- Run
/reportto summarize the results as a table
Rules
1. Benchmark Best Practices
- Each benchmark must be isolated
- Run many times for consistency
- Use realistic data representative of real use cases
- Minimize test framework overhead
2. Metrics To Collect
ops/sec- operations per secondavg time- average execution timemin/max- min/max execution timesamples- number of samples
3. Conditional Execution
- If the project has no benchmark files, skip the running steps
- If there are no baseline results, skip the comparison steps
- If a monorepo has multiple workspaces, run benchmarks one workspace at a time
Expected Outcome
- Benchmarks run successfully
- Metrics fully recorded (
ops/sec,avg time,min/max,samples) - Regressions and improvements identified
- Action items for optimization recorded