<script>ec(2);</script>
//创建一个对象
$timer = new Benchmark_Timer();
//计时开始
$timer->start();
//测试的一段脚本
for ($i=0; $i{
//we do nothing here
}
//设置标记
$timer->setMarker("Mark1");
//输出两点之间的用时
echo $timer->timeElapsed("Start", "Mark1");
?>
然后执行之,就可以得到0.000543这样的结果,大致为从开始到Mark1点之间的耗时.
类方法
方法:Benchmark_Timer( [mixed $auto = false])
描述:构造器,开始计时器记录.
参数:boolean $auto,缺省为false,如果设定为true的话,则会自动打印计时器结果.形如下表
time index ex time %
Start 1099020859.80505200 - 0.00%
Stop 1099020859.80595000 0.000898 100.00%
total - 0.000898 100.00%
分别列出开始/终止的时间索引,与上一标记之间的运行时间,与上一标记之间的运行时间占总耗时的百分比(所以Stop点一直为100%),以及总耗时.
方法: display( )
描述:打印由getOutput方法返回的信息.
形如下表:
time index ex time %
Start 1099021292.32145600 - 0.00%
Mark1 1099021292.32202000 0.000564 46.38%
Mark2 1099021292.32209700 0.000077 6.33%
Stop 1099021292.32267200 0.000575 47.29%
total - 0.001216 100.00%
列出每一标记的时间索引,与上一标记之间的运行时间,与上一标记之间的运行时间占总耗时的百分比,以及总耗时.
调用该方法前,应该先调用stop()来终止计时(并不会终止程序).见例2. 方法: getOutput( )
描述:返回格式化后的计时器信息. 该方法把计时器信息放如一个表中(如上表),供display()方法列出.
方法:getProfiling( )
描述:返回计时器信息.将是形如
Array
(
[0] => Array
(
[name] => Start
[time] => 1099021787.69669100
[diff] => -
[total] => 1099021787.696691
)
[1] => Array
(
[name] => Mark1
[time] => 1099021787.69675900
[diff] => 0.000068
[total] => 1099021787.696759
)
[2] => Array
(
[name] => Mark2
[time]
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Oguri Cap Build Guide | A Pretty Derby Musume
3 weeks agoByJack chen
Agnes Tachyon Build Guide | A Pretty Derby Musume
3 weeks agoByJack chen
Grass Wonder Build Guide | Uma Musume Pretty Derby
2 weeks agoByJack chen
PEAK How to Emote
1 months agoByJack chen
How to Fix KB5060829 Not Installing & Other Reported Bugs
3 weeks agoByDDD

Hot Tools

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use






