From: Florent Bruneau Date: Sat, 10 Nov 2007 22:36:50 +0000 (+0100) Subject: Add a new PlProfiler tool based on PlBacktrace. X-Git-Tag: xorg/0.9.16~210 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=58f9dc78229079745f20c50c13db39898deef96d;p=platal.git Add a new PlProfiler tool based on PlBacktrace. To use: Just add PlProfiler::start("category", "event"); PlProfiler::stop("category"); so, if you want both to profile a loop and each step of the loop: PlProfiler::start("my loop"); for ($i = 0 ; $i < 2000 ; ++$i) { PlProfiler::start("my step", $i); do_sth(); PlProfiler::stop("my step"); } PlProfiler::stop("my loop"); The result will be displayed as a backtrace by category. Signed-off-by: Florent Bruneau --- diff --git a/ChangeLog b/ChangeLog index 25fbb14..0098811 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ VERSION 0.9.16 XX XX 2007 New: + * Core: + - New PlProfiler tool -FRU + * Carnet: - List updated fields in notifications -FRU diff --git a/classes/plprofiler.php b/classes/plprofiler.php new file mode 100644 index 0000000..3b66426 --- /dev/null +++ b/classes/plprofiler.php @@ -0,0 +1,49 @@ +debug & DEBUG_BT)) { + return false; + } + if (!isset(PlBacktrace::$bt[$name])) { + new PlBacktrace($name); + } + PlBacktrace::$bt[$name]->start($info); + return true; + } + + static public function stop($name) + { + global $globals; + if (!($globals->debug & DEBUG_BT)) { + return false; + } + PlBacktrace::$bt[$name]->stop(); + return true; + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?>