以下类定义了一个计时器,将你的执行脚本加入到”容器”内即可(请看注释)
\n<?
\nclass timer
\n{ var StartTime = 0;
\nvar StopTime = 0;
\nvar TimeSpent = 0;\nfunction
start(){
\nthis->StartTime = microtime();}
\n function stop(){
\n this->StopTime = microtime();}
\n function spent(){
\n if (this->TimeSpent) {
\n return this->TimeSpent;
\n } else {
\nStartMicro = substr(this->StartTime,0,10);
\nStartSecond = substr(this->StartTime,11,10);
\nStopMicro = substr(this->StopTime,0,10);
\nStopSecond = substr(this->StopTime,11,10);
\nstart = doubleval(StartMicro) + StartSecond;
\nstop = doubleval(StopMicro) + StopSecond;
\nthis->TimeSpent = stop - start;
\nreturn substr(this->TimeSpent,0,8).“秒”;
\n }
\n }// end function spent();
\n}//end class timer;
\n//例子
\n timer = new timer;
\n timer->start();
\n/*
\n你的代码放在此处
\n*/\ntimer->stop();
\necho “执行本SCRIPT共”.timer->spent();
\n?>
\n