如果你关注php,那么你会发现Zend Optimizer+将要包含在php5.5中发布。并且Zend Optimizer+更名为zend opcache。那么zend opcache的性能到底如何呢?今天我们就和另一款opcode的cache软件APC做下比较。
软件版本如下:
PHP 5.4.14 (cli) (built: May 8 2013 18:05:07)
APC-3.1.13
ZendOpcache-7.0.2
测试的php脚本程序使用的是基于thinkphp框架开发的一个小博客程序。为了尽量减少其它因素影响,我对博客程序做了些改动,去掉了mysql数据库相关操作。
为了保证测试数据的准确性,进行了三轮测试。测试数据如下。
第一轮测试,先测试的zend opcache,并修改了部分参数,然后测试的apc,最后测试的zend opcache全部使用默认参数:
zend opcache【全部使用默认参数】
Time per request: 218.892 [ms] (mean)
Time per request: 233.750 [ms] (mean)
Time per request: 225.486 [ms] (mean)
Time per request: 230.526 [ms] (mean)
Time per request: 249.896 [ms] (mean)
Time per request: 241.296 [ms] (mean)
Time per request: 241.272 [ms] (mean)
Time per request: 236.686 [ms] (mean)
Time per request: 234.598 [ms] (mean)
Time per request: 243.302 [ms] (mean)
zend opcache【修改了部分配置】
Time per request: 211.284 [ms] (mean)
Time per request: 213.878 [ms] (mean)
Time per request: 202.549 [ms] (mean)
Time per request: 210.509 [ms] (mean)
Time per request: 206.334 [ms] (mean)
Time per request: 210.611 [ms] (mean)
Time per request: 209.081 [ms] (mean)
Time per request: 211.761 [ms] (mean)
Time per request: 214.675 [ms] (mean)
Time per request: 210.638 [ms] (mean)
APC【全部使用默认参数】
Time per request: 236.561 [ms] (mean)
Time per request: 248.693 [ms] (mean)
Time per request: 236.677 [ms] (mean)
Time per request: 235.124 [ms] (mean)
Time per request: 248.536 [ms] (mean)
Time per request: 240.039 [ms] (mean)
Time per request: 246.429 [ms] (mean)
Time per request: 247.005 [ms] (mean)
Time per request: 239.666 [ms] (mean)
Time per request: 242.129 [ms] (mean)
第二轮测试数据:
zend opcache【全部使用默认参数】
Time per request: 269.357 [ms] (mean)
Time per request: 243.429 [ms] (mean)
Time per request: 234.217 [ms] (mean)
Time per request: 230.216 [ms] (mean)
Time per request: 261.117 [ms] (mean)
zend opcache【修改了部分配置】
Time per request: 248.208 [ms] (mean)
Time per request: 236.992 [ms] (mean)
Time per request: 227.789 [ms] (mean)
Time per request: 238.858 [ms] (mean)
Time per request: 238.003 [ms] (mean)
APC【全部使用默认参数】
Time per request: 261.495 [ms] (mean)
Time per request: 282.167 [ms] (mean)
Time per request: 259.667 [ms] (mean)
Time per request: 273.712 [ms] (mean)
Time per request: 254.184 [ms] (mean)
第三轮测试数据:
zend opcache【全部使用默认参数】
Time per request: 241.913 [ms] (mean)
Time per request: 239.036 [ms] (mean)
Time per request: 256.463 [ms] (mean)
Time per request: 281.751 [ms] (mean)
Time per request: 260.563 [ms] (mean)
zend opcache【修改了部分配置】
Time per request: 274.961 [ms] (mean)
Time per request: 273.531 [ms] (mean)
Time per request: 252.983 [ms] (mean)
Time per request: 253.536 [ms] (mean)
Time per request: 243.620 [ms] (mean)
APC【全部使用默认参数】
Time per request: 272.575 [ms] (mean)
Time per request: 277.876 [ms] (mean)
Time per request: 254.808 [ms] (mean)
Time per request: 247.737 [ms] (mean)
Time per request: 254.162 [ms] (mean)
说明:
1. zend opcache的修改配置参数内容如下:
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
2.可能由于zend opcache修改部分参数,是第一个测试,导致其性能明显好于apc。
3.在第二轮和第三轮中,都是先测试apc。
总结:
根据上面的ab测试数据,可以肯定zend opcache 比apc性能要好。效率大概提升 5%-9% .