CodeIgniter: Measure Page Load Time
How do I measure the page load time in a CI application that is using Smarty? Right now, I have put benchmark points at the beginning and end of the index() method, but that only measures the execution time of the method, right? I want to know how long it take to fully re开发者_运维问答nder a page.
Just insert {elapsed_time}
into a html view:
like <p>Page rendered in {elapsed_time} seconds.
When you have a fresh install of Codeigniter, just open the default welcoming page. You can find this line in the footer.
CodeIgniter has a Benchmarking class that is always active, enabling the time difference between any two marked points to be calculated.
An alternate way to show your elapsed time in your view files is to use this pseudo-variable ...
I would point you to the Codeigniter Profiler
When used in conjunction to the Benchmarking, it gives you fairly detailed results, this should be exactly what you are looking for.
make sure you adjust your benchmark points to conform to the profiler specs though.
if you are using firefox, try the network
tab of firebug, it will show you how long it will download all the page's elements, that kind of information cannot be presented just by the profiller
If you install xdebug, you can get that information much better than using Codeigniter's profiler. Even better is to use calgrind and read those logs. I would advice you to have a look at these excellent slides of PHP author. I even advice you to watch the video, if some things aren't clear from the slides.
The best to test complete request is to use a tool as siege. It will bombard your page with requests to get a better picture how it performs under load.
The Profiler Class will display benchmark results like time taken to load , queries run etc.
To Enable Profiler in Codeigniter
$this->output->enable_profiler(TRUE);
Watch you page footer you will see complete detail when Application Run.
To Disabled Profiler
$this->output->enable_profiler(FALSE);
精彩评论