summaryrefslogtreecommitdiffstats
path: root/system/libraries/Profiler.php
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-03 05:40:45 +0200
committeradmin <devnull@localhost>2006-10-03 05:40:45 +0200
commitd13ff07599e9ff114051f4823c4c0d13fd1c814d (patch)
treed8e1cb36672910c5549be79718eb1c6e36b15c67 /system/libraries/Profiler.php
parent243f5cc45f23436a1ed3f2fc1ac5f0388dc3d4f5 (diff)
Diffstat (limited to 'system/libraries/Profiler.php')
-rw-r--r--system/libraries/Profiler.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
new file mode 100644
index 000000000..026bfac60
--- /dev/null
+++ b/system/libraries/Profiler.php
@@ -0,0 +1,72 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * Code Igniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package CodeIgniter
+ * @author Rick Ellis
+ * @copyright Copyright (c) 2006, pMachine, Inc.
+ * @license http://www.codeignitor.com/user_guide/license.html
+ * @link http://www.codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Code Igniter Profiler Class
+ *
+ * This class enables you to display benchmark, query, and other data
+ * in order to help with debugging and optimization
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Rick Ellis
+ * @link http://www.codeigniter.com/user_guide/libraries/benchmark.html
+ */
+class CI_Profiler {
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * 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 private
+ * @return array
+ */
+ function _compile_benchmarks()
+ {
+ $obj =& get_instance();
+
+ $times = array();
+ foreach ($obj->benchmark->marker as $key => $val)
+ {
+ // We match the "end" marker so that the list ends
+ // up in the order that it was defined
+ if (preg_match("/(.+?)_end/i", $key, $match))
+ {
+ if (isset($obj->benchmark->marker[$match[1].'_end']))
+ {
+ $times[$match[1]] = $obj->benchmark->elapsed_time($match[1].'_start', $key);
+ }
+ }
+ }
+
+ return $times;
+ }
+
+ // --------------------------------------------------------------------
+
+}
+
+// END CI_Profiler class
+?> \ No newline at end of file