All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Zend,Framework,1.0正式版即将发布_php资料_编程技术
LINQ体验(15)——LINQ,to,SQL语句之用户定义函数_[Asp.Net教程]
怎样在Web开发中完美控制IE标题栏_[Asp.Net教程]
SQLServer2000企业版安装教程(2)_[SQL,Server教程]
ASP.NET配置(web.config)无法连接到SQL,Server,数据库的解决方法_[Asp.Net教程]
如何用VB存取SQL,Server中的图像数据_[Asp.Net教程]
PHP取得当前插入数据库中记录的id值_php资料_编程技术
从,PHP,迁移到,ASP.NET(1)_[Asp.Net教程]
C#,Enum设计和使用的相关技巧_.net资料_编程技术
VS2005,中调试JavaScript的方法_[Asp.Net教程]
Reading number is top 10 pictures
The Soviet union swimsuit exposure in the 70 year3
Li Zongrui hunting video screenshots1
美女浴室写真3
In the world the most mysterious 21 place landscape2
Very beautiful interior decoration
Nine school beauty star those gossip matters
美丽的桂林风光1
The money of more than 100 countries and regions17
HongMenYan premiere XinLiangGong clairvoyant outfit PK YiFeiLiu1
Sora aoi in China3
Download software ranking
双旗镇刀客B
Dance with duck(male prostitution)
变速齿轮3.26
WebService在.NET中的实战应用教学视频 → 第5集
Call Of Duty5
Photoshop 8.0图象编辑软件
Boxer's Top ten classic battle6
WebService在.NET中的实战应用教学视频 → 第4集
jBuilder2006
The Bermuda triangle1
aaa published in(发表于) 2013/12/21 22:26:19 Edit(编辑)
PHP程序加速探索之脚本执行速度测试_php资料_编程技术

PHP程序加速探索之脚本执行速度测试_php资料_编程技术

PHP程序加速探索之脚本执行速度测试_php资料_编程技术-你的首页-uuhomepage.com
  前面有提到,只有找到影响速度的代码,我们才有可能进行优化。PEAR的benchmark包中的Benchmark_Timer类和Benchmark_Iterate类,可以用来很方便地测试脚本执行的速度。(关于PEAR的安装与配置请自行查看相关资料) 。

  首先用Benchmark_Iterate类来测试程序中某个函数或类的某个方法的执行时间。

  benchmark1.php


require_once('Benchmark/Iterate.php');
$benchmark = new Benchmark_Iterate();

$benchmark->run(10, 'myFunction','test');
$result = $benchmark->get();
echo "

"; print_r($result); echo "
";
exit;

function myFunction($var) {
// do something
echo 'Hello ';
}

?>
  建立benchmark Iterate对象$benchmark,这个对象用来执行myFunction函数10次。

  $argument变量每次都传递给myFunction. 多次运行的分析结果存入$result,然后用benchmark对象的get()方法来获取。这个结果用print_r()输出到屏幕。通常会输出这样的结果:

Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello


Array
(
[1] => 0.000427 [2] => 0.000079 [3] => 0.000072 [4] => 0.000071 [5] => 0.000076 [6] => 0.000070 [7] => 0.000073 [8] => 0.000070 [9] => 0.000074 [10] => 0.000072 [mean] => 0.000108 [iterations] => 10)
  myFunction的每次执行,benchmark对象都会跟踪执行时间。并且会计算平均的执行时间([mean]那一行)。通过多次运行目标函数,你可以得到该函数的平均运行时间。

  在实际测试中,函数的次数应当至少1000次左右,这样可以得到较客观的结果。




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.