Ant learning PHP performance optimization (1)

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

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.