# Speed up slow code

Finds performance bottlenecks and suggests faster approaches with measurable trade-offs.

- Topic: Software Development
- Framework: RTF
- Level: Standard
- Tags: Coding, Code, Fill-in Template
- Source: https://www.thinkwithprompt.com/prompts/speed-up-slow-code

## Prompt

```text
Help me make this code faster.

**Language/runtime:** [DETAILS]
**Code:**
[PASTE]
**What's slow and how I measured it:** [timings, profiler output, data sizes]
**Constraints:** [memory, readability, can't change interface]

Deliver:
1. Likely bottlenecks, with the reasoning (complexity, I/O, allocations, N+1 queries, etc.).
2. Optimizations ranked by expected gain vs. effort, with code for the top ones.
3. How to benchmark before and after to confirm the gain.
4. Trade-offs introduced (readability, memory, correctness risks).

Don't micro-optimize at the cost of clarity unless the gain is significant.
```

## What to fill in

- DETAILS
- PASTE
- timings, profiler output, data sizes
- memory, readability, can't change interface

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
