php 测试工具代码

        function convert($size){
             $unit=array('B','KB','MB','GB','TB','PB');
             return @round($size/pow(1024,($i=floor(log($size,1024)))),2).''.$unit[$i];
         }
         $mStart = memory_get_usage();
         $start = microtime(true);
         //any code
         $end = microtime(true);
         $mEnd = memory_get_usage();
         echo 'MEMORY: <span style="font-weight:bold; color: red;">'.
         convert($mEnd-$mStart) . '</span>  '.
         'RUNTIME: <span style="font-weight:bold; color: red;">'.
         sprintf('%0.7f',$end - $start) . '</span><br />';

 

posted @ 2014-11-18 08:39  appsolution  阅读(127)  评论(0)    收藏  举报