summaryrefslogtreecommitdiffstats
path: root/user_guide/libraries
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-10-02 23:59:12 +0200
committeradmin <devnull@localhost>2006-10-02 23:59:12 +0200
commite26611f93bfb21f5e143cc91ce529f6db52cdd88 (patch)
tree575b6b71408d25e6f4067b2a1533e0255fac707e /user_guide/libraries
parentb8afd045b9ed165bdae0d18b3e6f7483a4566e1c (diff)
Diffstat (limited to 'user_guide/libraries')
-rw-r--r--user_guide/libraries/benchmark.html54
1 files changed, 53 insertions, 1 deletions
diff --git a/user_guide/libraries/benchmark.html b/user_guide/libraries/benchmark.html
index 7f3e28bf5..b8b0bfd32 100644
--- a/user_guide/libraries/benchmark.html
+++ b/user_guide/libraries/benchmark.html
@@ -73,7 +73,20 @@ two marked points to be calculated.</p>
invoked, and ended by the output class right before sending the final view to the browser, enabling a very accurate
timing of the entire system execution to be shown.</p>
-<h2>Using the Benchmark</h2>
+
+<h3>Table of Contents</h3>
+
+<ul>
+<li><a href="#using">Using the Benchmark Class</a></li>
+<li><a href="#execution">Displaying Total Execution Time</a></li>
+<li><a href="#memory">Displaying Memory Consumption</a></li>
+<li><a href="#profiler">Auto Profiler</a></li>
+</ul>
+
+
+
+<a name="using"></a>
+<h2>Using the Benchmark Class</h2>
<p>The Benchmark class can be used within your <a href="../general/controllers.html">controllers</a>, <a href="../general/views.html">views</a>, or your <a href="../general/models.html">Models</a>. The process for usage is this:
@@ -111,6 +124,7 @@ echo $this->benchmark->elapsed_time('cat', 'bird');<br />
echo $this->benchmark->elapsed_time('dog', 'bird');</code>
+<a name="execution"></a>
<h2>Displaying Total Execution Time</h2>
<p>If you would like to display the total elapsed time from the moment Code Igniter starts to the moment the final output
@@ -128,6 +142,7 @@ output is sent to the browser. It doesn't matter where you use the function cal
<p class="important"><strong>Note:</strong> If you want to benchmark anything within your controller
functions you must set your own start/end points.</p>
+<a name="memory"></a>
<h2>Displaying Memory Consumption</h2>
<p>If your PHP installation is configured with --enable-memory-limit, you can display the amount of memory consumed by the entire
@@ -140,6 +155,43 @@ system using the following code in one of your view file:</p>
<code>{memory_usage}</code>
+<a name="profiler"></a>
+<h2>Auto Profiler</h2>
+
+<p>When the "auto profiler" is enabled, you'll see a report printed at the bottom of your pages containing a list of
+execution times for all benchmarks you have set throughout your application. This information can help you optimize your program.</p>
+
+<p class="important"><strong>Note:</strong> Even though this is a feature of the Benchmark class you will enable it from the Output class as indicated below.</p>
+
+<p>To enable the profiler place the the following function anywhere within your Controllers:</p>
+<code>$this->output->enable_profiler(TRUE);</code>
+
+<p>When enabled you'll see a table of execution times at the bottom of your pages.</p>
+
+<p>To disable the profiler you will use:</p>
+<code>$this->output->enable_profiler(FALSE);</code>
+
+<p>Important: In order to use this feature all of your marked points must end with <kbd>_start</kbd> and <kbd>_end</kbd>, and
+each pair of points must otherwise be named identically. Example:</p>
+
+<code>
+$this->benchmark->mark('my_mark<kbd>_start</kbd>');<br />
+<br />
+// Some code happens here...<br />
+<br />
+$this->benchmark->mark('my_mark<kbd>_end</kbd>');
+<br /><br />
+
+$this->benchmark->mark('another_mark<kbd>_start</kbd>');<br />
+<br />
+// Some more code happens here...<br />
+<br />
+$this->benchmark->mark('another_mark<kbd>_end</kbd>');
+
+</code>
+
+
+
</div>
<!-- END CONTENT -->