Interview question
How do you profile a PHP application to find performance bottlenecks? PHP application को profile करके performance bottlenecks कैसे ढूंढें?
Answer
| Tool | Purpose |
|---|---|
| Xdebug profiler | Function-level call graphs and timing |
| Blackfire | Production-safe profiling with visual call graphs |
| Laravel Telescope / Debugbar | Query counts, timing, memory per request |
| New Relic / Datadog APM | Application-wide monitoring in production |
// Basic manual timing
$start = microtime(true);
$result = expensiveOperation();
$duration = microtime(true) - $start;
error_log("Operation took: {$duration}s");
// Memory usage
echo memory_get_peak_usage(true) / 1024 / 1024 . ' MB';Workflow: Identify slow endpoint → Profile with Xdebug/Blackfire → Find hot function → Check for N+1 queries or missing cache → Fix → Re-measure
| Tool | उद्देश्य |
|---|---|
| Xdebug profiler | Function-level timing |
| Blackfire | Production-safe profiling |
| Laravel Telescope | Query counts, timing per request |
$start = microtime(true);
$result = expensiveOperation();
$duration = microtime(true) - $start;
error_log("Operation took: {$duration}s");Was this answer clear?