Professional CodeIgniter

(singke) #1

Chapter 9: Security and Performance


292


will need to recompile PHP with the - - enable - memory - limit flag set. In other words, having to reinstall
PHP may or may not be worth your time, depending on the kind of visibility you want on profiling.)

This kind of information is good, but what if you were trying to diagnose a more specific problem, like
how long a specific query was taking? You could, for example, put the following markers down in your
welcome/cat() function:

function cat($id){
$this- > benchmark- > mark(‘query_start’);
$cat = $this- > MCats- > getCategory($id);
$this- > benchmark- > mark(‘query_end’);
//function continues on...
}

Then, in your footer view, you could use elapsed_time() to print out the results:

& nbsp; & nbsp; & nbsp;
Elapsed query time:
< ?php echo $this- > benchmark- > elapsed_time(‘query_start’,’query_end’);? >

Simply reload a category page to see something like Figure 9 - 4.

Figure 9-4
Free download pdf