blob: 60ef585efb02b3b1cfc28409fd4056c52f9d4f64 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001##########################
2Profiling Your Application
3##########################
4
5The Profiler Class will display benchmark results, queries you have run,
6and $_POST data at the bottom of your pages. This information can be
7useful during development in order to help with debugging and
8optimization.
9
10Initializing the Class
11======================
12
13.. important:: This class does NOT need to be initialized. It is loaded
14 automatically by the :doc:`Output Class <../libraries/output>` if
15 profiling is enabled as shown below.
16
17Enabling the Profiler
18=====================
19
20To enable the profiler place the following function anywhere within your
21:doc:`Controller <controllers>` functions::
22
23 $this->output->enable_profiler(TRUE);
24
25When enabled a report will be generated and inserted at the bottom of
26your pages.
27
28To disable the profiler you will use::
29
30 $this->output->enable_profiler(FALSE);
31
32Setting Benchmark Points
33========================
34
35In order for the Profiler to compile and display your benchmark data you
36must name your mark points using specific syntax.
37
38Please read the information on setting Benchmark points in :doc:`Benchmark
39Class <../libraries/benchmark>` page.
40
41Enabling and Disabling Profiler Sections
42========================================
43
44Each section of Profiler data can be enabled or disabled by setting a
45corresponding config variable to TRUE or FALSE. This can be done one of
46two ways. First, you can set application wide defaults with the
47application/config/profiler.php config file.
48
49::
50
51 $config['config']          = FALSE; $config['queries']         = FALSE;
52
53In your controllers, you can override the defaults and config file
54values by calling the set_profiler_sections() method of the :doc:`Output
55class <../libraries/output>`::
56
57 $sections = array(     'config'  => TRUE,     'queries' => TRUE     ); $this->output->set_profiler_sections($sections);
58
59Available sections and the array key used to access them are described
60in the table below.
61
62Key
63Description
64Default
65**benchmarks**
66Elapsed time of Benchmark points and total execution time
67TRUE
68**config**
69CodeIgniter Config variables
70TRUE
71**controller_info**
72The Controller class and method requested
73TRUE
74**get**
75Any GET data passed in the request
76TRUE
77**http_headers**
78The HTTP headers for the current request
79TRUE
80**memory_usage**
81Amount of memory consumed by the current request, in bytes
82TRUE
83**post**
84Any POST data passed in the request
85TRUE
86**queries**
87Listing of all database queries executed, including execution time
88TRUE
89**uri_string**
90The URI of the current request
91TRUE
92**session_data**
93Data stored in the current session
94TRUE
95**query_toggle_count**
96The number of queries after which the query block will default to
97hidden.
9825