search
HomeBackend DevelopmentPHP Tutorialphp opcache 效果测试

测试环境

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ lscpu

Architecture:          i686

CPU op-mode(s):        32-bit, 64-bit

Byte Order:            Little Endian

CPU(s):                4

On-line CPU(s) list:   0-3

Thread(s) per core:    2

Core(s) per socket:    2

Socket(s):             1

Vendor ID:             GenuineIntel

CPU family:            6

Model:                 37

Stepping:              2

CPU MHz:               1199.000

BogoMIPS:              4521.76

Virtualization:        VT-x

L1d cache:             32K

L1i cache:             32K

L2 cache:              256K

L3 cache:              3072K

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ free -m

             total       used       free     shared    buffers     cached

Mem:          1869       1654        215        265          4        526

-/+ buffers/cache:       1123        745

Swap:         3320          1       3319



??未安装opcache测试??

lyolzj@localhost ~ $ ab -n 1000 -c 10 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      10

Time taken for tests:   79.554 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    12.57 [#/sec] (mean)

Time per request:       795.536 [ms] (mean)

Time per request:       79.554 [ms] (mean, across all concurrent requests)

Transfer rate:          111.70 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.0      0       0

Processing:   258  793 163.7    771    2227

Waiting:      249  777 163.1    755    2227

Total:        258  793 163.7    771    2227


Percentage of the requests served within a certain time (ms)

  50%    771

  66%    822

  75%    849

  80%    867

  90%    926

  95%    963

  98%   1040

  99%   1901

 100%   2227 (longest request)

lyolzj@localhost ~ $ ab -n 1000 -c 100 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      100

Time taken for tests:   81.475 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    12.27 [#/sec] (mean)

Time per request:       8147.464 [ms] (mean)

Time per request:       81.475 [ms] (mean, across all concurrent requests)

Transfer rate:          109.06 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   1.0      0       5

Processing:   232 7758 1533.2   7921    9906

Waiting:      220 7740 1532.2   7908    9893

Total:        237 7758 1532.3   7921    9906


Percentage of the requests served within a certain time (ms)

  50%   7921

  66%   8258

  75%   8488

  80%   8682

  90%   9020

  95%   9289

  98%   9531

  99%   9674

 100%   9906 (longest request)




安装opcache

lyolzj@localhost /usr/local/src $ sudo wget http://pecl.php.net/get/zendopcache-7.0.5.tgz

lyolzj@localhost /usr/local/src $ sudo tar -zxf zendopcache-7.0.5.tgz 

lyolzj@localhost /usr/local/src $ cd zendopcache-7.0.5/

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ ls

config.m4                     zend_accelerator_debug.c

config.w32                    zend_accelerator_debug.h

CREDITS                       ZendAccelerator.h

LICENSE                       zend_accelerator_hash.c

Optimizer                     zend_accelerator_hash.h

README                        zend_accelerator_module.c

shared_alloc_mmap.c           zend_accelerator_module.h

shared_alloc_posix.c          zend_accelerator_util_funcs.c

shared_alloc_shm.c            zend_accelerator_util_funcs.h

shared_alloc_win32.c          zend_persist.c

tests                         zend_persist_calc.c

zend_accelerator_blacklist.c  zend_persist.h

zend_accelerator_blacklist.h  zend_shared_alloc.c

ZendAccelerator.c             zend_shared_alloc.h

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo /usr/local/php5.4/bin/phpize 

Configuring for:

PHP Api Version:         20100412

Zend Module Api No:      20100525

Zend Extension Api No:   220100525

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo ./configure --with-php-config=/usr/local/php5.4/bin/php-config

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo make

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo make install

Installing shared extensions:     /usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/


配置opcache

在php.ini中添加

zend_extension= /usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525/opcache.so

[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


lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      2549/php-fpm.conf)

tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN   

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo kill 2549

lyolzj@localhost /usr/local/src/zendopcache-7.0.5 $ sudo /usr/local/php5.4/sbin/php-fpm -y /usr/local/php5.4/etc/php-fpm.conf


lyolzj@localhost ~ $ ab -n 1000 -c 10 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      10

Time taken for tests:   27.116 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    36.88 [#/sec] (mean)

Time per request:       271.158 [ms] (mean)

Time per request:       27.116 [ms] (mean, across all concurrent requests)

Transfer rate:          327.70 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.4      0       5

Processing:   190  270  55.9    260     628

Waiting:      185  263  54.2    254     625

Total:        190  270  56.1    260     632


Percentage of the requests served within a certain time (ms)

  50%    260

  66%    282

  75%    301

  80%    313

  90%    341

  95%    368

  98%    398

  99%    443

 100%    632 (longest request)

lyolzj@localhost ~ $ ab -n 1000 -c 100 http://localhost/wordpress/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        nginx/1.6.3

Server Hostname:        localhost

Server Port:            80


Document Path:          /wordpress/

Document Length:        8886 bytes


Concurrency Level:      100

Time taken for tests:   28.363 seconds

Complete requests:      1000

Failed requests:        0

Total transferred:      9099000 bytes

HTML transferred:       8886000 bytes

Requests per second:    35.26 [#/sec] (mean)

Time per request:       2836.330 [ms] (mean)

Time per request:       28.363 [ms] (mean, across all concurrent requests)

Transfer rate:          313.28 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    1   1.7      0       7

Processing:    86 2700 515.9   2804    3322

Waiting:       81 2692 515.3   2797    3311

Total:         94 2700 514.3   2804    3322


Percentage of the requests served within a certain time (ms)

  50%   2804

  66%   2853

  75%   2886

  80%   2909

  90%   3025

  95%   3127

  98%   3186

  99%   3223

 100%   3322 (longest request)


结果

    由Time per request:       81.475 [ms] 变成Time per request:       28.363 [ms];提升了近3倍。


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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.