Small ant learning php performance Optimization (1)

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.