Profiling Your Application¶
The Profiler Class will display benchmark results, queries you have run,
$_POST data at the bottom of your pages. This information can be
useful during development in order to help with debugging and
Initializing the Class¶
This class does NOT need to be initialized. It is loaded automatically by the Output Library if profiling is enabled as shown below.
Enabling the Profiler¶
To enable the profiler place the following line anywhere within your Controller methods:
When enabled a report will be generated and inserted at the bottom of your pages.
To disable the profiler you will use:
Setting Benchmark Points¶
In order for the Profiler to compile and display your benchmark data you must name your mark points using specific syntax.
Please read the information on setting Benchmark points in the Benchmark Library page.
Enabling and Disabling Profiler Sections¶
Each section of Profiler data can be enabled or disabled by setting a corresponding config variable to TRUE or FALSE. This can be done one of two ways. First, you can set application wide defaults with the application/config/profiler.php config file.
$config['config'] = FALSE;
$config['queries'] = FALSE;
In your controllers, you can override the defaults and config file
values by calling the
set_profiler_sections() method of the
$sections = array(
'config' => TRUE,
'queries' => TRUE
Available sections and the array key used to access them are described in the table below.
|Elapsed time of Benchmark points and total execution time
|CodeIgniter Config variables
|The Controller class and method requested
|Any GET data passed in the request
|The HTTP headers for the current request
|Amount of memory consumed by the current request, in bytes
|Any POST data passed in the request
|Listing of all database queries executed, including execution time
|The URI of the current request
|Data stored in the current session
|The number of queries after which the query block will default to hidden.
Disabling the save_queries setting in
your database configuration will also effectively disable profiling for
database queries and render the ‘queries’ setting above useless. You can
optionally override this setting with
$this->db->save_queries = TRUE;.
Without this setting you won’t be able to view the queries or the