CodeIgniter Tip: Time Your Pages
Sarfraz Ahmed April 21, 2015 01:39 PMFor one of pages in the CodeIgniter application, I needed to find out how much time it takes to load. Pretty obviously first thing that came to mind was to use its built-in Benchmarking Class:
$this->benchmark->mark('code_start');
// Some code happens here
$this->benchmark->mark('code_end');
echo $this->benchmark->elapsed_time('code_start', 'code_end');
That's fine as long as you need to benchmark specific points/parts in your code.
But if you need to find out overall time page took to load, you can actually use below variable in your views:
{elapsed_time}
Or simply:
<?php echo $elapsed_time;?>
That variable is automatically created by CodeIgniter.