Use hypothesis testing to improve program speed

An agent explored speedup ideas, kept only the ones that stayed correct, and saved the verified changes in Git.

Done with Claude Code· Advanced

What they did
A developer set up Claude Code with a specific benchmark, a success metric, a correctness rule set, and a time budget. Once started, the agent inspected the program’s performance, framed each attempt as a falsifiable guess, made a small code commit, and checked both speed and correctness after every change. If the change failed either test, it was undone; if it passed, it remained in the branch history.
How it went
For KaHIP kaffpa, the process produced 122 runs from 69 hypotheses and preserved 41 patches, ending at 3.9x faster overall. VieCut reached 8.9x, with all cuts unchanged from the original. Verified patches were compared directly against the baseline output before being kept.
Tips
Decide exactly what counts as correct before the agent begins, because it only tests the rules you provide. If you want a low-risk trial, start with the 10-minute quick-start example first.

Try it yourself with Claude Code

In [project or codebase], have Claude Code profile [benchmark command] and look for the biggest slowdowns. Then work in a loop: propose one falsifiable speedup idea, apply the smallest code change needed, run [verification command] to check [correctness requirement], rerun [benchmark command], and retain the change only if the result is both valid and faster. If it fails, roll it back and try a different idea. After [number] attempts or once progress stalls, write a short PDF summary covering the starting measurement, each idea, the measured result, and the final speed improvement. Before any action that would remove, submit, or send work outside the repo, stop and ask me for approval.

Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.

Get 3 agent uses like this every morning

With the day's top AI news. Free, and one click to unsubscribe.