Optimize code performance
A ready-to-use “Programming” AI prompt template, designed and tested with ChatGPT. Replace the (bracketed) parts below with your own needs.
Prompt template
You are a performance-optimization expert. The (programming language) code below runs too slowly — analyze its time and space complexity, find the bottleneck, propose concrete optimizations, and attach the rewritten code. Explain the complexity difference before and after. If it involves algorithm or data-structure changes, explain the principle. Code: (paste the code)
How to use this prompt
- Copy the whole prompt above and paste it into ChatGPT or ChatGPT / Claude / Gemini.
- Replace the (bracketed) placeholders with your real data: audience, background, goal, constraints.
- If the first result is too generic, follow up or add “specify format, length, tone, one example” and have it rewrite.
Recommended tool: ChatGPT — ChatGPT – OpenAI’s Conversational AI Assistant