惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
月光博客
月光博客
IT之家
IT之家
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
小众软件
小众软件
C
Check Point Blog
B
Blog RSS Feed
H
Help Net Security
博客园 - 司徒正美
L
LangChain Blog
MongoDB | Blog
MongoDB | Blog
B
Blog
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - KIS

五种常见的ASP.NET安全缺陷 如何防止控制客户端使其用同一帐户重复登录系统 VBscript常用函数 ASP.NET中计算两个日期之间的相差的天数的方法 ASP.NET程序中常用的33种代码 - KIS - 博客园 实用代码集锦 - KIS - 博客园 实用代码(Javascript脚本) - KIS - 博客园 利用ASP技术实现文件直接上传功能 如何利用ASP把图片上传到数据库 CSDN如何把图片存入到数据库 用VB将ASP代码封装成DLL 多个表单和多个图片一起上传完美解决方案 HTML七种加密解密 - KIS - 博客园 JS常用脚本、html代码大全、对联广告代码效果大全 - KIS - 博客园 HTML代码大全 一些常用/不常用的html代码 - KIS - 博客园 用鼠标滚轮实现图片的缩放 - KIS - 博客园 ASP中几种分页显示的比较 - KIS - 博客园 Windows 2000/XP/2003环境下IIS+PHP+MYSQL安装配置
计算页面执行时间的PHP小程式
KIS · 2007-04-12 · via 博客园 - KIS

<?php
class timer
{
    var $StartTime = 0;
    var $StopTime = 0;

    function get_microtime()
    {
        list($usec, $sec) = explode(' ', microtime());
        return ((float)$usec + (float)$sec);
    }

    function start()
    {
        $this->StartTime = $this->get_microtime();
    }

    function stop()
    {
        $this->StopTime = $this->get_microtime();
    }

    function spent()
    {
        return round(($this->StopTime - $this->StartTime) * 1000, 1);
    }

}

//例子
$timer = new timer;
$timer->start();
//你的代码开始
$a = 0;
for($i=0; $i<1000000; $i++)
{
    $a += $i;
}
//你的代码结束
$timer->stop();

echo "页面执行时间: ".$timer->spent()." 毫秒";
?>

测试通过....