In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the php performance optimization points for attention, the article is very detailed, has a certain reference value, interested friends must read!
Under what circumstances, you may encounter performance problems:
Inappropriate use of 1.php syntax
two。 Using php language to do what it's not good at.
3. The service connected in php language is not powerful.
The deficiency of 4.php itself
5. A problem I don't know.
General situation: php performance problems are no more than 1/2 (generally 30% to 40%)
Direction of php performance problem resolution:
Performance optimization at the php language level-> performance optimization for php peripheral issues (connected services, network environment)-> php language self-analysis and optimization
(php language level)
Optimization: write less code and use more of php's own capabilities
Problem: self-written code has more redundancy and poor readability, resulting in low performance
Why low: php code needs to be compiled and parsed into the underlying language, which is processed every time a request is made, which is expensive.
Method: use php built-in variables, constants and functions more often
Optimization point: the performance of php built-in functions
Situation description: php built-in functions, there is still a difference between the speed
Suggestion: learn more about the time complexity of php built-in functions
Optimization point: use as few magic functions as possible
Description: the magic function provided by php has poor performance
Why low performance: the php language has done a lot for you to save trouble for php programmers
Good way: avoid using php magic functions as much as possible
Optimization point: error suppressors that generate extra overhead @
Actual logic: set the highest error level before the start of the code, and then reply to set the error level after the end. Add Opcode and ignore error report
Optimization point: rational use of memory
Description: php has a memory recovery mechanism to protect the bottom, but please use memory carefully.
Suggestion: use unset () to release unsuitable memory in time (Note: unset () cannot be logged out)
Optimization points: use regular expressions as little as possible
Description: the backtracking cost of the expression is high, "don't do ceramic work without diamond".
Suggestion: use string processing function to realize the same logic
Optimization points: avoid doing operations in a loop
Situation description: the formula within the loop will be repeated.
Optimization point: reduce computing-intensive business
Situation description: php is not suitable for intensive computing scenarios
Why? The characteristics of php language determine that php is not suitable for large data operations.
Php is suitable for scenarios: suitable for connecting Webserver with back-end services and UI rendering.
Optimization points: be sure to use quoted strings as key values
Description: php will treat key values without quotation marks as constants, resulting in the overhead of finding constants
Suggestion: strictly use quotation marks as key values
-
(performance optimization of php peripheral issues)-
Running environment, file storage, database, cache, network
Reduce file class operations
The cost order of common php scenarios:
Read-write disk, read-write database, read-write memory, read-write network data
Read and write memory
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.