just do it

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

php计算函数执行时间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
class lib_times
{ 
    var $starttime;
    var $stoptime;
    var $spendtime;
 
    function getmicrotime()
    {
        list($usec,$sec)=explode(" ",microtime());
        return ((float)$usec + (float)$sec);
    }
 <span id="more-458"></span>
    function start()
    {
        $this->starttime=$this->getmicrotime();
    }
 
    function display()
    {
        $this->stoptime=$this->getmicrotime();
        $this->spendtime=$this->stoptime-$this->starttime;
        echo "<p>Processed in". round($this->spendtime,6)."second(s). </p>";
     }
}
//实例化时间类
$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();
 
 
?>
点赞