Track execution time of each request

How to track exection time of each request in Hour:minutes:seconds microseconds ?

I have done as below but how to track it with microseconds?


public function actionIndex(){


    $start_time         = date("H:i:s");


    // Functionality to execute ...


    $end_time           = date("H:i:s");

    $diff               = strtotime($end_time)-strtotime($start_time);

    $execution_time     = gmdate("H:i:s",$diff);

}

Edit 1 - is it right way?


$start_time = microtime(true);


// looping or functionality ...

$time_taken  = round(microtime(true) - $start_time,4);

list($sec,$msec)= explode(".", $time_taken);

$execution_time = date("i",$sec)."m : ".date("s",$sec)."s  : ".$msec."ms";

Yii’s logging features might be helpful, specifically performance profiling

http://www.yiiframework.com/doc/guide/1.1/en/topics.logging#performance-profiling

You should be able to profile every request by extending CController and hooking your profile blocks inside the beginAction and afterAction methods