Capstone — the Tunebox Cost Lab
In short: instrument a function with a counter on its dominant operation,
measure it at sizes that double, and the growth rate falls out of the
ratio between neighbouring counts (×2 linear, ×4 quadratic). For a precise
exponent, take logs of both n and the count: on a log-log plot a power law
a·n^b becomes a straight line whose slope is b. The lab then checks that
slope against the bound you proved on paper — and settles the n log n vs
n^1.1 ambiguity by dividing the counts by each candidate model and seeing
which one leaves a flat line.

You now have two ways of knowing what code costs. On paper: read a recurrence off the code, solve it with a recursion tree, account for spikes with a bank of tokens, average over random pivots. In the machine: count the operations while the code runs. Each one checks the other. A proof with a slip in it disagrees with the count, and a count taken on an unlucky input disagrees with the proof.
The capstone puts them together in one instrument. The cost lab takes a function from sections 1 to 6, runs it on inputs of growing size, counts its real operations, fits a curve to the counts, and reports the exponent. You then compare that exponent with the bound you derived.
Step 1: instrument
Timing with a stopwatch measures your laptop. Counting measures the code. Pick the operation that dominates, the one inside the innermost loop, and add a counter there. For insertion sort from section 3 that is the shift:
A reversed list of four needs 6 shifts, a sorted one needs none. Which input you measure on matters as much as how you count, so the lab always states it: worst case (reversed), best case (sorted), or a seeded random input for the average.