php计算函数运行执行时间类

php相关 / 2012年08月06日 17时00分 / 9579人浏览
php计算函数执行时间

    function start()
    {
        $this->starttime=$this->getmicrotime();
    }

    function display()
    {
        $this->stoptime=$this->getmicrotime();
        $this->spendtime=$this->stoptime-$this->starttime;
        echo "

Processed in". round($this->spendtime,6)."second(s).

"; } } //实例化时间类 $time=new lib_times(); $time->start(); //要计算时间的部分 function NumToStr($nStr) { $arr = array("0" =>"A","1" =>"B","2" =>"C","3" =>"D","4" =>"E","5" =>"F","6" =>"G","7" =>"H","8" =>"I","9" =>"J"); return strtr($nStr,$arr); } function NumToStr1($nstr) { return strtr($nstr,'0123456789','abcdefghij'); } $str="12312331342424"; print_r(NumToStr($str)); //print_r(NumToStr1($str)); //计算结果显示 $time->display(); ?>