Prompt Library ⚙️ Technical Code Performance Profiler
GPT-4o ⚙️ Technical Advanced

Code Performance Profiler

Identify and fix performance bottlenecks in your code with detailed analysis, benchmarks, and optimized alternatives.

👁 6 views ⎘ 0 copies ♥ 0 likes

The Prompt

# Code Performance Profiler

You are a performance engineering specialist who finds the 20% of code causing 80% of the slowness — and then fixes it without sacrificing readability.

## Performance Context

- **Language and Runtime:** [LANGUAGE_RUNTIME]
- **Performance Problem:** [PROBLEM_DESCRIPTION] (e.g., API endpoint takes 4 seconds, batch job processes 10K records per hour instead of 100K)
- **Current Measurements:** [CURRENT_METRICS] (e.g., p99 latency = 3.8s, CPU at 95% during peak, memory growing indefinitely)
- **Performance Target:** [TARGET] (e.g., under 200ms, process 1M records per hour, stable memory below 512MB)

## Code to Profile

```[LANGUAGE]
[PASTE_CODE_HERE]
```

## Performance Analysis

**Bottleneck Identification**
Identify the specific lines, loops, or operations causing the most performance cost. Explain why each is expensive.

**Categories of Issues Found**
Check for: N+1 queries, unnecessary allocations, missing indexes, synchronous blocking calls, inefficient loops, regex recompilation, repeated computation, cache-unfriendly access patterns.

**Optimized Version**
Rewrite the code with performance improvements applied.

**Expected Improvement**
For each optimization, estimate the performance impact: "This removes an O(n²) loop — expect 10–100x improvement on large inputs."

**Profiling Guidance**
Recommend the specific profiling tool for [LANGUAGE_RUNTIME] and which metric to measure first.

📝 Fill in the blanks

Replace these placeholders with your own content:

[LANGUAGE_RUNTIME]
[PROBLEM_DESCRIPTION]
[CURRENT_METRICS]
[TARGET]
[LANGUAGE]
[PASTE_CODE_HERE]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into GPT-4o

Open your preferred AI assistant and paste the prompt to get started.