Ant Financial learns about PHP performance optimization (1) because sphinx has not found any suitable materials, he will start learning about PHP performance optimization today. I remember that a long time ago, I used this function to calculate the funds and resources of all recommenders under a level-1 network, as well as the funds and resources of each recommender, which forms a human pulse tree, the practice at that time was to use a recursive method for computing, where the database was constantly queried and the resource consumption was quite large. when there were 100 or 200 direct and indirect recommenders under one person, that is why it cannot be run. this is indeed a headache for a long time. Today, it is necessary to learn about PHP explained by experts.
Solutions to PHP performance problems
PHP language-level performance optimization
Performance Optimization of PHP peripheral problems
PHP language analysis optimization
Stress testing tools
Apache Benchmark (AB)
Introduction: AB is a stress testing software provided by Apache.
Use:./AB-n1000-c100 http://www.sina.com
-N requests-c concurrency url target stress test address
After this command is run, there are two parameters:
Requests per second 101.65 ms (several requests can be accepted per second) this value is as high as possible
Time per request 9.838 ms (time consumed by a single request) this value is as small as possible
PHP language-level performance optimization
1. Optimization: less code and more PHP capabilities
Performance problems: Self-writing code is redundant, with poor readability and low performance.
Why is performance low? PHP code needs to be compiled and parsed to the underlying language. this process will be processed once every request, with high overhead.
Good method: Use PHP built-in variables, constants, and functions.
2. Optimization: the performance of PHP built-in functions
Situation description: PHP built-in functions, there are still slow differences between them
Good suggestion: Learn more about the time complexity of PHP built-in functions.