measure-before-optimizing

Installation
SKILL.md

Measure Before Optimizing

Knuth's rule is almost always quoted at half strength. The full sentence, from "Structured Programming with go to Statements" (1974): "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%." That's two obligations, not one — don't tune noncritical code on a hunch, and find and fix the critical fraction. Knuth adds how to tell them apart: it's "often a mistake to make a priori judgments" about what's critical, because programmers' intuitive guesses fail once measurement tools are applied. Hence the discipline: reproduce, measure, fix the highest-leverage cause, measure again.

Why profile first: Amdahl's law

Total speedup is capped by the fraction of runtime the code you're touching actually occupies: speedup = 1 / ((1 − p) + p/s) for a fraction p made s times faster.

Installs
11
GitHub Stars
1
First Seen
Jun 25, 2026
measure-before-optimizing — morzecrew/agent-skills