Code performance review prompt: find bottlenecks

Paste code to get bottlenecks identified with their complexity impact, plus concrete optimizations and their trade-offs.

بواسطة ‪Ahmed Eid‬‏Claude0 نسخة

متى تستخدم هذا البرومبت

  • When a function or endpoint is measurably slow.
  • Before scaling a system to significantly more load.
  • When reviewing a hot path flagged by profiling.

نص البرومبت

Review this {{language}} code for performance issues, focusing on {{focus}}. Identify bottlenecks, their complexity impact, and suggest concrete optimizations with trade-offs.

{{CLIPBOARD}}
{{language}}{{focus}}{{CLIPBOARD}}

الكتلة {{CLIPBOARD}} تُستبدل تلقائياً بما نسخته قبل الضغط على «نسخ».

كيف تستخدمه

  1. انسخ البرومبت بالزر أو املأ المتغيرات أولاً.
  2. الصقه في ChatGPT أو Claude أو Gemini.
  3. عدّل النتيجة أو أعد الطلب بتغيير المتغيرات.

مثال على النتيجة

Bottleneck: nested loop over items and orders is O(n*m); with 10k items this is ~100M comparisons.

Fix: build a Map keyed by order.itemId first, then look up in O(1) per item.

Trade-off: uses more memory to hold the map, but drops runtime from O(n*m) to O(n+m).

نصائح للاستخدام

  • Mention real data sizes (rows, requests/sec) so severity is judged correctly.
  • If you have profiler output, paste it alongside the code for a much sharper diagnosis.
  • Ask it to rank suggestions by impact vs. effort if you got several.

النماذج الموصى بها

Claude

أسئلة شائعة

Does it need profiling data to work?
No, it can reason from code structure alone, but real profiling numbers make the diagnosis far more precise.
Will suggested fixes always be safe to apply?
Treat them as candidates to test, not guaranteed-safe changes; benchmark before and after in your actual environment.

برومبتات ذات صلة

Generate a GraphQL Schema from a Description

Describe your data and operations in plain English and get a complete, documented GraphQL schema.

Design a GraphQL schema (types, queries, mutations) for: {{focus}}. Use {{language}} conventions and include field-level descriptions. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Generate Realistic Mock Data for Testing

Get realistic, varied mock data, including edge cases, matched to your schema, ready to seed a test database.

Generate {{focus}} realistic mock/test data records in {{language}} format for this schema or type, with varied and edge-case values. {{CLIPBOARD}}

{{focus}}{{language}}{{CLIPBOARD}}

Explain What This Legacy Code Actually Does

Paste unfamiliar or legacy code and get a plain-language walkthrough, with dead code and possible bugs flagged.

Walk through this {{language}} code line by line and explain what it does, in plain language. Flag anything that looks like dead code, a workaround, or a potential bug. {{CLIPBOARD}}

{{language}}{{CLIPBOARD}}

Generate a Dockerfile for Your App

Get a secure, optimized Dockerfile tailored to your language and framework, ready to build and run.

Write a production-ready Dockerfile for a {{language}} app using {{framework}}. Use multi-stage builds where useful, minimize image size, and run as a non-root user. Notes: {{focus}}. {{CLIPBOARD}}

{{language}}{{framework}}{{focus}}{{CLIPBOARD}}
المزيد في برمجة