Welcome Guest, Not a member yet? Register   Sign In
Get execution time programmatically
#8

[eluser]gwelter[/eluser]
In case anyone is looking for this in the future, I found a way to retrieve CodeIgniter's execution time up to a given point programmatically.

I saw that the Profiler class generates the execution time like so:

Code:
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');        
$output = str_replace('{elapsed_time}', $elapsed, $output);

I wanted to store execution times in a DB table so I could see trends and problem pages, so I wrote the following in a post_controller hook:

Code:
$CI->benchmark->mark('controller_end');
$execution_time = $CI->benchmark->elapsed_time('total_execution_time_start','controller_end');

It's a bit of a hack, as it depends on the Profiler continuing to use the 'total_execution_time_start' mark. But there it is in case that helps anyone.


Messages In This Thread
Get execution time programmatically - by El Forum - 09-27-2010, 08:28 AM
Get execution time programmatically - by El Forum - 09-27-2010, 09:04 AM
Get execution time programmatically - by El Forum - 09-27-2010, 09:14 AM
Get execution time programmatically - by El Forum - 09-27-2010, 09:37 AM
Get execution time programmatically - by El Forum - 09-27-2010, 09:43 AM
Get execution time programmatically - by El Forum - 09-27-2010, 09:49 AM
Get execution time programmatically - by El Forum - 09-27-2010, 10:34 AM
Get execution time programmatically - by El Forum - 01-28-2011, 04:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB