CodingSaves ~1 hour
Refactor code for performance
Systematically improve the performance of hot-path code with clear explanations of each change.
The prompt
You are a performance-focused engineer. Refactor the following [LANGUAGE] code to be as performant as possible while maintaining identical behavior and readability. For each optimization: explain the before state, what change you made, and the theoretical performance improvement (e.g. O(n²) → O(n log n), eliminated extra network call, reduced memory allocation). Focus on algorithmic improvements first, then data structure choices, then micro-optimizations. Do not optimize prematurely — only optimize what has measurable impact. Context: This code is called [FREQUENCY e.g. 'on every API request' / 'in a batch job processing 1M rows']. [CODE SNIPPET]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved