Apache üstüne bir canlı sistem için PHP Profiler

7 Cevap php

Ben bir Apache sunucu üzerinde bir PHP web sitesi var, ve ben araçları ve ben kodu darboğazları bulmak için bu profili başka yolları olup olmadığını bilmek istiyorum. Ne bilmeniz gereken fonksiyonlar, vb işlemek için uzun alıyor nedir

Canlı apache sunucu üzerinde PHP dışında gprof'ın gibi bir şey.

PHP sisteminde darboğazları bulmak için diğer yolları nelerdir.

7 Cevap

DTrace düşük yüke sahiptir

dtrace in fact has almost zero overhead unless you enable thousands of probes think it is also available on the BSD's

Bu iş için phpdebug kullanabilirsiniz. Bu bir php uzantısı bulunuyor.

Ben kendi profilcisini bina karşı öneririm. Size geniş detay ve kullanım kolaylığı verecek serbestçe kullanılabilir birkaç mükemmel profilleyicilerini vardır. Ben senin en iyi zaman yatırım aşağıdaki kombinasyon olduğunu düşünüyorum. Biz çalışmak için, ve onunla çok mutluyuz web developent şirkette bu kullanın:

  1. The Zend Server php stack:
    You can use the free Community Edition, and choose which parts of the stack you want to install. We installed only the PHP part, and rely on the Apache and MySQL from the Linux distro. Zend Server provides a Debugger extension, a code optimizer (for a slight speed boost), a bytecode cache (for a substantial speed boost) and a nice GUI for managing PHP settings. The commercial version provides much more. Installation in Linux is easy via RPM or DEB packages.

  2. To use the Debugger extension you need an IDE:
    Install Zend Studio which is an excellent PHP IDE (check the features page), and makes debugging and profiling very easy. No need to make cachegrind files, or other multistep processes, but just click Profile in the toolbar in Firefox and Studio starts profiling that page. The detail and ease of use are huge.

Belki Zend satıcı gibi sondaj ediyorum ve belki de bu ihtiyacın daha fazla gibi geliyor, ama o kullandığı araçları ile çok mutlu olduğunu, sadece bir PHP geliştiricisi değilim. Ben iyi Studio'yu kullanarak başlamak için harcanan zaman olduğunu düşünüyorum, ama kombinasyon harika yapar ve Server, hatta canlı sunucuyu biraz hızlandırır. Bence bu combo sadece şu anda mevcut en iyi PHP geliştirme ortamıdır. demo videos göz atın. Da profil biri var.

Yüklü kez şekillerde çeşitli profiling of requests tetikleyebilir, ve her istek için bir valgrind biçim profili ile rüzgar - Sen xdebug kullanabilirsiniz. WinCacheGrind, KCacheGrind veya benzeri bu yükleyin ve her zaman nereye harcandığını bulmak için detaya!

alt text

(http://www.xdebug.org/), hata ayıklama-oturumu sırasında bir get-parametre ile tetikleyebilir XDebug sahipsiniz. Bu KCacheGrind veya WinCacheGrind (bu ilk daha iyidir) içinde kontrol edebilirsiniz cachegrind dosyaları yaratacak ...

XHProf was designed for this use case.

XHProf (2009'da Facebook tarafından açık kaynaklı) güçler Facebook'un XHProfLive - üretim katmanda gelen fonksiyon seviyesi anlayışlar sağlayan gerçek zamanlı performans izleme sistemi.

XHProf doc A pasajı:

XHProf is a light-weight instrumentation based profiler. During the data collection phase, it keeps track of call counts and inclusive metrics for arcs in the dynamic callgraph of a program. It computes exclusive metrics in the reporting/post processing phase. XHProf handles recursive functions by detecting cycles in the callgraph at data collection time itself and avoiding the cycles by giving unique depth qualified names for the recursive invocations.

XHProf's light-weight nature and aggregation capabilities make it well suited for collecting "function-level" performance statistics from production environments.

regards, Kannan Muthukkaruppan

Eğer bakmak için bir çok hedefli alan varsa, kodunuz çevresinde bu yağmurlama denemek isteyebilirsiniz:

$f_timeStart=microtime(true);
$f_timeLast=$f_timeStart;


error_log(sprintf("%'08.5f",(microtime(true)-$f_timeLast)).' - '.sprintf("%'05.2f",(microtime(true)-$f_timeStart)).' secs - '.'01 before xyz()'."\n", 3, '/var/tmp/my-errors.log');
$f_timeLast=microtime(true);
xyz();
error_log(sprintf("%'08.5f",(microtime(true)-$f_timeLast)).' - '.sprintf("%'05.2f",(microtime(true)-$f_timeStart)).' secs - '.'01 after xyz()'."\n", 3, '/var/tmp/my-errors.log');
$f_timeLast=microtime(true);