您好,欢迎访问一九零五行业门户网

性能监控 - 如何检测PHP某个方法 在一次请求中调用了多少次,每次的耗时和耗内存情况?

如何检测php某个方法 在一次请求中调用了多少次,每次的耗时和耗内存情况?
回复内容: 如何检测php某个方法 在一次请求中调用了多少次,每次的耗时和耗内存情况?
function microtime_float (){ list( $usec , $sec ) = explode ( , microtime ()); return ((float) $usec + (float) $sec );} function test(){ static $num = 0; $num ++; $memory = memory_get_usage () ; $time_start = microtime_float (); // 操作过程略 usleep ( 100 ); $m = memory_get_usage () -$memory;//内存 $t = microtime_float () -$time_start;//耗时 return [$num,$m,$t];}test();test();print_r(test());array( [0] => 3 [1] => 0 [2] => 0.00016498565673828)
或许你需要这个
配置下xdebug + kcachegrind就好了。
其它类似信息

推荐信息