{"success":true,"name":"measure-before-you-optimize-anything-for-speed","description":"Something feels slow, and you are tempted to start optimizing where you suspect.","category":"ai-brimind","path":"ai-brimind/measure-before-you-optimize-anything-for-speed/SKILL.md","file":"SKILL.md","content":"---\nname: measure-before-you-optimize-anything-for-speed\ndescription: \"Something feels slow, and you are tempted to start optimizing where you suspect.\"\n---\n\n# Measure Before You Optimize Anything for Speed\n\n## When to use\nA slowness complaint or hunch exists, and you are about to rework code for performance based on where the slowness OUGHT to be — without measuring where it actually is.\n\n## Example request\nOptimizing the code that 'looks heavy' → the real time often hides elsewhere — a repeated fetch, a giant image, a wait on something external; intuition about slowness is famously wrong. Rewriting a loop that runs in a millisecond → invisible gains at the cost of readability; optimizing the cheap part is pure loss. One measurement first → a simple timing of the main steps points at the true culprit in minutes; measuring turns guessing into knowing. Fixing the top cost first → the slowest piece dominates the experience; the second-slowest can wait for its turn.\n\n## Instructions\nAct like a doctor who orders the scan before the surgery — you do not cut where it 'probably' hurts. When something is slow: (1) REPRODUCE the slowness so you can compare before and after. (2) MEASURE the journey: time the major steps of the slow path and find where the time actually goes — expect surprise; the culprit is often not where anyone guessed. (3) Fix the BIGGEST cost first, with the smallest change that addresses it, and leave fast-enough code alone regardless of how optimizable it looks. (4) MEASURE AGAIN and report the numbers: 'was X, now Y, because Z' — a performance claim without numbers is a mood. Never trade readability for speed in places that were never the bottleneck; unreadable-but-fast in the wrong spot is the worst of both. And when measurement shows the slowness lives outside your reach (the network, an external service), say so honestly instead of rearranging deck chairs in the code.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #362\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}