^Status|Draft|
^Todo|Needs to be expanded with examples maybe|
====== Profiler Library ======
The Profiler adds useful information to the bottom of the current page for debugging and optimization purposes.
* **Benchmarks:** The times and memory usage of benchmarks run by the [[core:benchmark|Benchmark library]].
* **Database Queries:** The raw SQL of queries executed through the [[libraries:database|Database library]] as well as the time taken and number of affected rows.
* **POST Data:** The names and values of any POST data submitted to the current page.
* **Session Data:** All data stored in the current session if using the [[libraries:session|Session library]].
* **Cookie Data:** The names and values of any cookies found for the current domain.
===== How to use =====
To enable the profiler output on your pages simply load the library:
$this->profiler = new Profiler;
When loaded the profiler will add itself to the ''system.display'' event, calling the ''render()'' method when the page is being displayed and attaching the output to the bottom of the page.
===== How to disable =====
The automatic rendering of the output can be disabled with the following code:
$this->profiler->disable()
This is mostly useful when autoloading the profiler to disable the output for certain pages.
===== Getting the output =====
The rendered output may be returned as a string at any time during the page execution by passing TRUE as the first parameter in ''render()'':
$output = $this->profiler->render(TRUE)
Note: This will stop any benchmarks currently being run. Only benchmarks and queries that have been run up until this call will be shown in the output.
=====Configure the profiler =====
Edit ''config/profiler.php'' to configure which items (post, cookie, session, database, benchmarks) the profiler will show.
This change is made to ''application/config/profiler.php'' so as to apply only to the specific application.
/**
* Show everything except database queries. (Other entries are default TRUE, read from system profiler config.
*/
$config['database'] = FALSE;
A complete profiler.php would look like this
Remember to set at least one of the items to TRUE otherwise the profiler will die in a trace error.
**Note**: To enable database benchmarking, you will also need to update the following line in your ''config/database.php'' file: 'benchmark' => TRUE,