<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

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

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

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues
3 weeks agoByDDD
How to fix KB5055523 fails to install in Windows 11?
2 weeks agoByDDD
InZoi: How To Apply To School And University
4 weeks agoByDDD
How to fix KB5055518 fails to install in Windows 10?
2 weeks agoByDDD
Roblox: Dead Rails – How To Summon And Defeat Nikola Tesla
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

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