summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/general/profiling.rst
blob: 60ef585efb02b3b1cfc28409fd4056c52f9d4f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##########################
Profiling Your Application
##########################

The Profiler Class will display benchmark results, queries you have run,
and $_POST data at the bottom of your pages. This information can be
useful during development in order to help with debugging and
optimization.

Initializing the Class
======================

.. important:: This class does NOT need to be initialized. It is loaded
	automatically by the :doc:`Output Class <../libraries/output>` if
	profiling is enabled as shown below.

Enabling the Profiler
=====================

To enable the profiler place the following function anywhere within your
:doc:`Controller <controllers>` functions::

	$this->output->enable_profiler(TRUE);

When enabled a report will be generated and inserted at the bottom of
your pages.

To disable the profiler you will use::

	$this->output->enable_profiler(FALSE);

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 :doc:`Benchmark
Class <../libraries/benchmark>` 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 :doc:`Output
class <../libraries/output>`::

	$sections = array(         'config'  => TRUE,         'queries' => TRUE         );          $this->output->set_profiler_sections($sections);

Available sections and the array key used to access them are described
in the table below.

Key
Description
Default
**benchmarks**
Elapsed time of Benchmark points and total execution time
TRUE
**config**
CodeIgniter Config variables
TRUE
**controller_info**
The Controller class and method requested
TRUE
**get**
Any GET data passed in the request
TRUE
**http_headers**
The HTTP headers for the current request
TRUE
**memory_usage**
Amount of memory consumed by the current request, in bytes
TRUE
**post**
Any POST data passed in the request
TRUE
**queries**
Listing of all database queries executed, including execution time
TRUE
**uri_string**
The URI of the current request
TRUE
**session_data**
Data stored in the current session
TRUE
**query_toggle_count**
The number of queries after which the query block will default to
hidden.
25