Since Sphinx has not found the right material, start learning PHP performance optimization today. Remember a long time ago to do such a function, is to calculate the first-level network of all the referrals of the funds and, as well as each referral of the recommendation of the Fund and, the formation of a network tree, then the practice is to use a recursive method to calculate, which constantly query the database, resource consumption is quite large, When a person below the direct referral and indirect referral to reach one hundred or two hundred, it will not be able to run, it really makes people headache for a long time. It is necessary to start learning about PHP as a master today.
How to solve the performance problem of PHP
PHP language-level performance optimization
Performance optimization for PHP peripheral problems
PHP Language self-analysis optimization
Pressure test tools
Apache Benchmark (AB)
Introduction: AB is a stress test software provided by Apache
Use:./ab-n1000-c100 http://www.sina.com
-N Number of requests-c concurrency URL target stress test address
After this command runs, the main thing to see is two parameters:
Requests per second 101.65ms (can accept several requests per second) This value is as high as possible
Time per request 9.838ms (one request) This value is as small as possible
PHP language-level performance optimization
1. Optimization point: Less code, more use of PHP's own capabilities
Performance problems: Self-writing code redundancy, readability is not strong, low performance.
Why is performance low? PHP code needs to be compiled and parsed into the underlying language, and this process is processed once per request, with a large overhead
Good method: Use PHP built-in variables, constants, functions.
2. Optimization point: PHP Built-in function performance advantages and disadvantages
Case Description: PHP built-in functions, there are still differences between the speed
Good advice: Learn more about the time complexity of PHP built-in functions.