zoukankan      html  css  js  c++  java
  • 最简单的记录程序运行时间的方法:[记录PHP程序运行消耗时间]

    比较实用的debug方法:具体参考地址已经记不清了,这里重写成类方便调用

    /**
     * @author logonmy@126.com
     * @Date: 13-7-23
     * @desc example to count application run time
     */
    class Interval{
     
        var $start;
     
        public function getTrueTime()
        {
            list($sec,$unix) = explode(' ',microtime());
            return (float)$unix+(float)$sec;
        }
     
        public function __construct()
        {
            $this->start = $this->getTrueTime();
        }
     
        public function spend()
        {
            return $this->getTrueTime() - $this->start;
        }
    }
     
    $interval = new Interval(); //创建一个对象并记录开始时间
     
    //----------------------\
     
    $n = 0;
    for($i=0;$i<=2000000;$i++)
    {
        $n+=$i;
    }
     
    //----------------------//
     
     
    echo $interval->start;       //开始时间:1374548014.8087
     
    echo '<br/>';
     
    echo $interval->getTrueTime();//结束时间 :1374548014.9211
     
    echo '<br/>';
     
    echo round($interval->spend(),4);//运行时间 :0.1124
  • 相关阅读:
    Building a Space Station POJ
    Networking POJ
    POJ 1251 Jungle Roads
    CodeForces
    CodeForces
    kuangbin专题 专题一 简单搜索 POJ 1426 Find The Multiple
    The Preliminary Contest for ICPC Asia Shenyang 2019 F. Honk's pool
    The Preliminary Contest for ICPC Asia Shenyang 2019 H. Texas hold'em Poker
    The Preliminary Contest for ICPC Asia Xuzhou 2019 E. XKC's basketball team
    robotparser (File Formats) – Python 中文开发手册
  • 原文地址:https://www.cnblogs.com/logon/p/3208081.html
Copyright © 2011-2022 走看看