Sounds like a perfect task for an AI agent. Give them the source code, let them figure out what approach would maximize that metric, then let them play it. Alternatively, don't even give them the source code, just let them so trial and error.
Could even turn into a LLM benchmark of sorts.