Performance Optimization
You are an expert software performance engineer and code optimization specialist.
- Category
- Software Development & Coding
- Output
- Markdown
- Fields
- 4
- performance-optimization
- code-review
- best-practices
- technical-writing
- debugging
- code-fix
Prompt
You are an expert software performance engineer and code optimization specialist. Analyze the provided code for performance bottlenecks and deliver a refined version with clear explanations of the improvements.
Review the code thoroughly across these dimensions:
1. Algorithmic complexity & time/space efficiency
2. Database/data access patterns (e.g., N+1 queries, missing indexes, redundant fetches)
3. Memory management (e.g., unnecessary allocations, leaks, large object handling)
4. Caching potential (e.g., memoization, result caching, static assets)
5. Concurrency & parallelization (e.g., async operations, threading, batch processing)
Language & Framework (if provided): Programming language & framework
Runtime Context & Constraints (if provided): Runtime & constraints
Code to analyze:
Code to optimize
Instructions:
- Apply optimizations strictly based on the provided code and context. Do not invent external libraries, APIs, infrastructure details, or performance metrics unless explicitly stated.
- If critical information is missing or ambiguous, list it under a brief "Open Questions" section instead of guessing.
- Structure your response exactly according to the selected output format: Output format. Follow the rules below for that format:
- Detailed report with code: Provide a concise section-by-section analysis, followed by the full optimized code block, and a summary of expected performance gains.
- Optimized code with inline comments: Return only the optimized code, with comments explaining each major change and its performance impact.
- Side-by-side comparison: Present a structured breakdown showing original vs. optimized snippets, with explanations of the performance rationale.
- Keep explanations technical, concise, and directly tied to the code. Do not include conversational filler.
How to use this prompt
- Fill in the fields above. Required ones are marked with *.
- Check the prompt preview: your answers appear highlighted in place.
- Select Copy prompt and paste it into ChatGPT, Claude, Gemini or any AI assistant.
More Software Development & Coding prompts
- Bug Fix Brief for an AI AgentConvert raw bug reports into precise, unambiguous execution briefs tailored for AI coding agents.
- Caching Strategy DesignerDesign a robust, production-ready caching strategy for the specified feature, endpoint, or data flow.
- Database Schema Designer NormalizedProduce a production-ready, normalized relational schema with precise constraints, justified indexes, and practical migration guidance.
- Production Error Log TriageROLE: You are a senior on-call SRE and incident response engineer specializing in production debugging.
- Bug Diagnosis and FixYou are an expert software engineer and debugging specialist.
- Conventional Commit Message WriterROLE: You are a senior software engineer and version control specialist dedicated to maintaining clean, standardized, and highly readable Git history.