What is the slowest php operation? -Php Tutorial

Source: Internet
Author: User
Assuming that a php script does not call any extension, what kind of operation is the slowest (most efficient )? Assuming that a php script does not call any extension, what kind of operation is the slowest (most efficient )? Reply content: IO operations. the execution efficiency of the PHP language for databases, networks, and files is roughly as follows:
(1) the fastest part is the language structure, such as for and foreach. they are part of the language syntax and are not functions, and their execution efficiency is the highest.
(2) the native and extended functions provided by PHP are relatively fast. they are implemented in C language, and the efficiency is in the same order of magnitude as that of C program, for example, various types of strings and array functions.
(3) the slowest is the PHP function written by a PHP programmer, which has the lowest efficiency. For example, the sorting algorithm function implemented by PHP is at least one order of magnitude slower than the native and extended functions.

Therefore, PHP is not suitable for computing-intensive work. it refers to the third point. However, if this work is implemented in the form of extensions, this problem will not occur.

However, in actual application scenarios, PHP language execution efficiency is much slower than network I/O, and the bottleneck is usually caused by various network transmission and backend Server time consumption. For example, when we read mysql once, it usually takes several dozen milliseconds to execute the Network + execution. However, for PHP program execution, it can easily complete thousands of function calls.

However, the PHP community is still continuously improving the implementation of the underlying PHP language and the engine, and further optimizing the language execution efficiency of PHP code. For example, PHP7 is a breakthrough in the innovative nature. Accessing the Internet, I/O is hard to hurt databases. databases are not suitable for executing intensive computing databases sleep (10086 ).

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.