How to force AI coding assistants to verify performance improvements
How toAgents & ToolsThe Neuron · 1d ago

How to force AI coding assistants to verify performance improvements

Software developers can stop coding bots from introducing broken or fake optimizations by requiring empirical proof for every speed claim. By following a scientific testing loop, the model must propose a hypothesis, run validation tests, and benchmark performance before committing changes.

Try it yourself

  1. 1Establish fixed benchmarks, test inputs, and strict output correctness requirements before altering code.
  2. 2Require the assistant to state a testable hypothesis explaining why a proposed change should improve runtime.
  3. 3Predict the performance gain using profiling data prior to writing any new logic.
  4. 4Make a single contained change and run tests to confirm the program output remains identical.
  5. 5Run the timing benchmark and discard the patch immediately if runtime does not improve.

Copy this prompt

Examine this slow code and sample input data: [insert code and inputs]. Suggest a single targeted optimization and explain why it should speed up execution. Provide a repeatable benchmark procedure to time performance before and after, along with a test ensuring outputs do not change. Do not claim the optimization works until the benchmarks and verification tests have finished running.
Heidelberg University
Read the original