Optimizing in measured rounds
Give GLM-5.1 a slow function or endpoint, a way to measure it and a rule that the output must not change. Have it change one thing per round and report the new timing, and keep the changes that a benchmark run confirms.
Example: How do we make this endpoint faster without changing its output?
Material
- Profile
- GET /orders, 50 orders: 1,900 ms total. 1 query for orders + 50 queries for customers: 1,500 ms. JSON encoding: 250 ms.
- Rule
- The response body must stay byte-for-byte the same.
PromptSpeed up GET /orders without changing the response. Change one thing at a time, say what you expect it to save, and wait for the measured result before the next change.
Sample answer · written by hand to show the reasoning
Round 1: load customers in one query (WHERE id IN the 50 IDs) instead of one per order. Most of the 1,500 ms is per-query overhead, so expect it to drop to roughly 100–200 ms; keep the response identical by mapping customers back by ID. Run the benchmark and the response comparison test, then send me the numbers. If encoding is still 250 ms after that, round 2 is to look at the serializer.