08.10.2017 Views

codeigniter_tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

20. Application Profiling<br />

CodeIgniter<br />

When building a web application, we are very much concerned about the performance of<br />

the website in terms of how much time the controller took to execute and how much<br />

memory is used. Not only the performance, but we also need to see the insights of data<br />

like POST data, data of database queries, session data etc. for debugging purpose while<br />

developing some application. CodeIgniter has made this job easier for us by profiling an<br />

application.<br />

Enable Profiling<br />

To enable profiling of your application, simply execute the command given below in any<br />

of the method of your controller.<br />

$this->output->enable_profiler(TRUE);<br />

The report of the profiling can be seen at the bottom of the page after enabling it.<br />

Disable Profiling<br />

To disable profiling of your application, simply execute the command given below in any<br />

of the method of your controller.<br />

$this->output->enable_profiler(FALSE);<br />

Enable / Disable Profiler Section<br />

Profiling can be done on section basis. You can enable or disable profiling of a section by<br />

setting a Boolean value TRUE or FALSE. If you want to set profiling on the application<br />

then you can do in a file located in application/config/profiler.php<br />

For example, the following command will enable profiling queries for the whole<br />

application.<br />

$config['queries'] = TRUE;<br />

In the following table, the key is the parameter, which can be set in the config array to<br />

enable or disable a particular profile.<br />

Key Description Default<br />

benchmarks<br />

Elapsed time of Benchmark points and total TRUE<br />

execution time<br />

config CodeIgniterConfig variables TRUE<br />

controller_info The Controller class and method requested TRUE<br />

get Any GET data passed in the request TRUE<br />

http_headers The HTTP headers for the current request TRUE<br />

75

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!