Measure Before Optimizing
Performance rules cover measuring before optimizing, benchmark provenance, single-run skepticism, correctness gates, and the cost of complexity or dependency churn.
Speed, memory, allocation, throughput, and benchmark evidence.
7 rules
Avoid Single-Run Performance ConclusionsPERF-AVOID-SINGLE-RUN-CONCLUSIONSDo not land performance conclusions from one short benchmark run. Repeat and contextualize timing evidence because warmup, scheduling, cache state, and background load can make a single result non-reproducible.Justify Complexity, Churn, and DependenciesPERF-JUSTIFY-COMPLEXITY-CHURN-AND-DEPENDENCIESExplain why a performance win justifies added complexity, churn, unsafe code, caching, or dependencies. Measured speedups still need to pay for the maintenance cost every future reader inherits.Measure Goal, Change, and ComparisonPERF-MEASURE-GOAL-CHANGE-COMPAREState the performance goal, baseline measurement, implementation change, and comparison result together. Those pieces let reviewers judge whether the patch improved the relevant workload enough to justify its tradeoffs.Optimize Measured HotspotsPERF-OPTIMIZE-MEASURED-HOTSPOTSOptimize code that measurement shows is on the important runtime path. This keeps review attention on changes whose user-visible impact justifies altering the code shape.Record Benchmark ProvenancePERF-RECORD-BENCHMARK-PROVENANCERecord the commands, inputs, tool versions, build profile, and runner conditions behind benchmark numbers. Provenance makes future comparisons meaningful and helps separate real changes from environment drift.Run Correctness Before TimingPERF-RUN-CORRECTNESS-FIRSTRun relevant correctness checks before interpreting performance timing. Fast code that changes behavior invalidates the benchmark claim and wastes review effort.Run Timing Benchmarks SequentiallyPERF-RUN-TIMING-BENCHMARKS-SEQUENTIALLYSerialize timing-sensitive benchmarks when their numbers will be used as evidence. Concurrent runs compete for shared resources and can make the comparison describe the runner more than the code.