GitHub Happy multi PHP Divine code trigger spit slot Hot

Source: Internet
Author: User

The other time, GitHub's PHP plate has been able to improve the efficiency of 70% of the code, triggering the world's many netizens spit and ridicule, "awesome! "," Well done! "," PHP is the world's first language! "It's always a hard-to-do, hard-to-do program that has fully played its humorous side, and GitHub has become a joyous ocean.

Let's take a look at this Divine code:

This code does one thing: Disable the PHP garbage collector. Then the user test after using the PHP-disabled garbage collector to bring the effect is:

Before:memory USAGE:163.66MB (PEAK:403.82MB), time:246.25s
After:memory USAGE:163.34MB (PEAK:350.36MB), time:99.55s
The time required for a PHP program to run is reduced from 246.25 seconds to 99.55 seconds!

Before:memory USAGE:152.71MB (PEAK:335.9MB), time:195.99s
After:memory USAGE:164MB (PEAK:308.02MB), time:104.06s
The time required for a PHP program to run is reduced from 195.99 seconds to 104.06 seconds!

......

In general, disabling the garbage collector can improve the efficiency of php70% operations.

Since PHP's garbage collection is so unreliable, what was it designed to do before?

Because memory management is a very troublesome thing in C + +, the use and release of memory require the programmer to write the program manual operation, if there is omission, it can cause resource waste and even memory leak. So PHP was designed to circumvent this problem by introducing a garbage collector to automatically release the memory of useless objects.

It is worth mentioning that PHP when running the loop recovery algorithm, will incur additional time consumption. While this extra cost is negligible in smaller projects, when running a large project, the consumption will have a significant impact due to the simultaneous initiation of multiple recycled threads, and the most intuitive manifestation is that the program runs longer.

Disabling PHP garbage collection is the simplest and most brutal way to improve the efficiency of your programs. This is like a leg injury, the simplest way is amputation.

As soon as the Divine Code was released, GitHub's handlers were happy to bloom:

The first Homm expressed surprise at this approach and did not understand why it was done, and objectively evaluated the way it looked and did not look good:

Then came the smileytechguy began to tease: "Well, there is no comment, let us put the PHP kernel disable it, we will not explain why this is done." ”

And then it started to get out of hand:

with soy sauce:

To have a groove and ridicule:

Just say that PHP is the world's first language, there are several countries version, saying that only a few pieces of code to improve the efficiency of 70%, PHP World first language is well-deserved:

There are also the sale of Moe:

PHP garbage collection mechanism has become a joke, we are also very clear that the simple disable PHP garbage collection does not solve the problem of memory overflow, PHP future how to handle the memory management and operational efficiency of the contradiction between will be a long way to go.

GitHub Happy multi PHP Divine code trigger spit slot Hot

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.