一个ZendOptimizer的困惑,让人不解?

冰泽水 2009-11-05 10:44:23
关于ZendOptimizer的困惑,让人不解?

今天在php环境中做了一个小测试,但测试结果相当让人不解.
所用版本:Apache2.2 + php-5.2.5-Win32

页面执行的测试代码如下:
命名为:test.php
<?php
class runtime
{
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);
}
}
$runtime= new runtime;
$runtime->start();
$a = 0;
for($i=0; $i<10000000; $i++){
$a += $i;
}
$runtime->stop();
echo "页面执行时间: ".$runtime->spent()." 毫秒";
?>
-----------------------------------------------------------------
测试一:在php.ini中不加载ZendOptimizer.dll时
在执行test.php时,10次统计时间如下:
2197.2
2253.6
2253.6
2293
2200.7
2170.9
2343.3
2148.4
2123.4
2157.3
-----------------------------------------------------------------
测试二:在php.ini中加载ZendOptimizer.dll时
加载方法如下:
[Zend]
zend_extension_ts="D:\web\php-5.2.5-Win32\ext\ZendOptimizer.dll"
zend_optimizer.optimization_level=15

经过phpinfo();的测试如下了以信息:
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
说明ZendOptimizer.dll加载成功

在执行test.php时,3次统计时间如下:
2420.6
2414.9
2408.7
-----------------------------------------------
按理在php中加载了ZendOptimizer.dll后,会使php的执行效率会提高40%-100%,
怎么我的加载之后不但没有使效率提高反面下降了呢?

请各位帮忙分析一下,错在那里.
...全文
216 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
冰泽水 2009-11-06
  • 打赏
  • 举报
回复
如果要将开发出来的php系统,用zendoptimizer提速,是否一定要用Zend Guard编码后才有效果呢?

经过测试编码后执行是快了一点.
冰泽水 2009-11-05
  • 打赏
  • 举报
回复
ab -n 1000 -c 50 http://192.168.1.198:88/index.php:

用这个查了一下,两者得到的数据是有一些不同.


但在运行整个站点的时候,还是没能感觉出来快
do_fork 2009-11-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xuan2002627 的回复:]
拿ab跑一下试试

ab不明白是什么东西?
[/Quote]

ab是apache跑性能测试的工具
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
-t timelimit Seconds to max. wait for responses
-b windowsize Size of TCP send/receive buffer, in bytes
-p postfile File containing data to POST. Remember also to set -T
-u putfile File containing data to PUT. Remember also to set -T
-T content-type Content-type header for POSTing, eg.
'application/x-www-form-urlencoded'
Default is 'text/plain'
-v verbosity How much troubleshooting info to print
-w Print out results in HTML tables
-i Use HEAD instead of GET
-x attributes String to insert as table attributes
-y attributes String to insert as tr attributes
-z attributes String to insert as td or th attributes
-C attribute Add cookie, eg. 'Apache=1234. (repeatable)
-H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
Inserted after all normal header lines. (repeatable)
-A attribute Add Basic WWW Authentication, the attributes
are a colon separated username and password.
-P attribute Add Basic Proxy Authentication, the attributes
are a colon separated username and password.
-X proxy:port Proxyserver and port number to use
-V Print version number and exit
-k Use HTTP KeepAlive feature
-d Do not show percentiles served table.
-S Do not show confidence estimators and warnings.
-g filename Output collected data to gnuplot format file.
-e filename Output CSV file with percentages served
-r Don't exit on socket receive errors.
-h Display usage information (this message)
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, or ALL)
海诗美妆 2009-11-05
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xuan2002627 的回复:]
拿ab跑一下试试

ab不明白是什么东西?
[/Quote]

ApacheBench,apache附带的用作性能测试的工具
http://zh.wikipedia.org/wiki/ApacheBench
冰泽水 2009-11-05
  • 打赏
  • 举报
回复
拿ab跑一下试试

ab不明白是什么东西?
do_fork 2009-11-05
  • 打赏
  • 举报
回复
不能这样测试,要测试从php加载到退出

拿ab跑一下试试
wdarray0829 2009-11-05
  • 打赏
  • 举报
回复
有没有用Zend 把php 源码转成二进制阿?如果没转,用不用 zendoptimizer 都一样

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧