Calculate Time Taken By A Query

Hi - How I can calculate the time taken by an Active Record Query?

Actually, I’m implementing “Query Caching” and I need to see if it is perfectly implemented or not. I need to check the time taken by a query with/without cache.

I have already tried the dirty PHP approach by marking start_time=time() and end_time=time() before and after the query respectively, but it is not seems to be helpful because both are giving same time and the result is remaining zero even without caching.

How I can check if my query is now improved or not?

Thanks,

Hi Verma

You can use microtime instead time function for more accuracy (before and after execution of query)

$exectime = microtime();

$exectime = explode(" ",$exectime);

$exectime = $exectime[1] + $exectime[0];

$starttime = $exectime;

Thanks Konapaz - I just don’t know, how I can forget “mircrotime()” for this :)

Thanks,

welcome to the best php framework :)

hmmm… Than please answer my below query:

[url="http://www.yiiframework.com/forum/index.php/topic/37107-how-to-cache-cdbcriteriacactivedataprovider-query/"]


http://www.yiiframework.com/forum/index.php/topic/37107-how-to-cache-cdbcriteriacactivedataprovider-query/

[/url]

:)

Thanks,

Ravi Verma