From e26611f93bfb21f5e143cc91ce529f6db52cdd88 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 2 Oct 2006 21:59:12 +0000 Subject: --- system/libraries/Benchmark.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'system/libraries/Benchmark.php') diff --git a/system/libraries/Benchmark.php b/system/libraries/Benchmark.php index d8dd903e7..feedbf570 100644 --- a/system/libraries/Benchmark.php +++ b/system/libraries/Benchmark.php @@ -85,6 +85,38 @@ class CI_Benchmark { // -------------------------------------------------------------------- + /** + * Auto Profiler + * + * This function cycles through the entire array of mark points and + * matches any two points that are named identially (ending in "_start" + * and "_end" respectively). It then compiles the execution times for + * all points and returns it as an array + * + * @access public + * @return array + */ + function auto_profiler() + { + $marker_keys = array_reverse(array_keys($this->marker)); + + $times = array(); + foreach ($marker_keys as $val) + { + if (preg_match("/(.+?)_start/i", $val, $match)) + { + if (isset($this->marker[$match[1].'_end'])) + { + $times[$match[1]] = $this->elapsed_time($val, $match[1].'_end'); + } + } + } + + return $times; + } + + // -------------------------------------------------------------------- + /** * Memory Usage * -- cgit v1.2.3-24-g4f1b