In the previous article "Smarty on the impact of Web page performance", the default does not open Opcache, so I installed a zend opcache extension, re-experiment, the results are as follows:
Have Smarty
Using Apache's AB command for stress testing, concurrent with 10, is not large, while using the SAR command to calculate the CPU utilization. The command is as follows:
./ab-c 10-n 100000 http://cq01-rdqa-dev072.cq01.baidu.com:8008/index.php
Sar-u 2 >/tmp/smarty.sar &
CPU utilization is counted every 2 seconds, fetch 23 rows of data, average later, cpu idle = 86.8535%, that is, the average CPU utilization is 13.1%, save 19.7% than not turn on Opcache
Collected 100,000 execution time logs with an average execution time of 0.000784178 seconds, saving about 10 milliseconds compared to Opcache.
The AB command shows the requests per second:2104.07 [#/sec] (mean), which increases by 1306 than does not turn on Opcache
No Smarty
CPU utilization is counted every 2 seconds, fetch 40 rows of data, average later, cpu idle = 92.8845%, that is, the average CPU utilization is 7.1%, save 2% than not turn on Opcache
200,000 execution time logs were collected, with an average execution time of 8.63295e-05 seconds, or 86.3296 microseconds, saving 93 microseconds compared to not turning on Opcache.
The AB command shows the requests per second:2478.31 [#/sec] (mean), which increases by 152 than does not turn on Opcache
Conclusion: It can be found that, after opening opcache, there are smarty cases, the performance has obvious improvement, can be said to be doubled. 20% increase in CPU without smarty, 50% savings in execution time
Without smarty, the number of lines of code is less, with dozens of rows, so the elevation is not obvious. There are smarty cases where the number of lines of code is more, plus the cache, so it is obvious.
In the case of opening opcache, there is a significant difference between smarty and smarty performance.
Smarty impact on Web page performance--Turn on Opcache