jacksonyang.dev AboutWorksInsightsContact 中文

Making a performance comparison honest

How I build · 5 November 2026 · Jackson Yang

A “look how much faster it got” demo earns its credibility from three things: identical behaviour before and after, a single change, and results you can verify on the spot.

I once prepared a performance demo: run the same batch program before a change and after it, and show the audience the difference. It sounds simple, yet it took me seven versions before I was willing to show it. Each version I threw away taught me something.

You can’t change the result to get the speed

In one version I merged five lines of calculation into one. The program really did get faster, but the grand total came out a million off.

The cause was rounding. Each of the original five lines truncated its result, so the value was truncated five times; after merging, only once. The behaviour had changed, so the demo was worthless: I was no longer comparing the same thing.

The rule after that: leave the program’s structure exactly as it is, and change only one thing. That time it was the format the numbers were stored in.

Pick the wrong example and there is nothing to see

In another version I chose division for the demo. Before and after were equally slow, because division is slow in itself and no storage format can rescue it. The example has to be somewhere the change really makes a difference; otherwise you are demonstrating an effect that doesn’t exist.

Don’t force the numbers

When the tool reported a “problem share” of around 25%, that was already a dramatic number. I could have pushed it higher, but at the cost of a program that looks fake, obviously contrived for the demo. One expert in the audience is all it takes for the whole session to lose its credibility.

The version that survived

The same loop ran 50 million times. CPU time dropped from 11.0 seconds to 9.06 seconds, about 20% faster. More importantly, the grand totals from the two runs were identical.

In the last thirty seconds of the demo I didn’t talk about performance at all. I did one thing: put the two sets of results side by side, so everyone could see that every number matched.

The audience won’t remember “about 20% faster”. They will remember “the results were exactly the same”. That sentence means: it made our program faster, not different. For someone about to hand over a core system, that second part is the reason they are willing to say yes.

Three conditions

  1. Identical behaviour before and after. The same logic, the same input, the same number of iterations.
  2. Change only one dimension. Change two things at once and you can’t say which one made the difference.
  3. Output you can verify. Totals, checksums, anything you can check on the spot.

Miss any one of them and it is just a video of something running faster.