Home > Backend Development > PHP Tutorial > Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

WBOY
Release: 2016-07-13 10:11:42
Original
1064 people have browsed it

Github’s joyful many PHP god-level codes have caused complaints, githubphp’s god code

The day before yesterday, a piece of code that can improve operating efficiency by 70% suddenly appeared on Github’s PHP section, triggering a nationwide stir. Many netizens around the world have complained and ridiculed, "awesome!", "well done!", "PHP is the world's first language!" Programmers who are usually serious and hardworking have given full play to their humorous side, and Github has become a joy of ocean.

First let’s take a look at this piece of god-level code:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

What this code does is one thing: disable PHP’s garbage collector. Then netizens tested the effect of using the garbage collector with PHP disabled:

<p>Before: Memory usage: 163.66MB (peak: 403.82MB), time: 246.25s<br />After: Memory usage: 163.34MB (peak: 350.36MB), time: 99.55s<br />某个PHP程序运行所需时间从246.25秒降低到99.55秒!</p>
<p>Before: Memory usage: 152.71MB (peak: 335.9MB), time: 195.99s<br />After: Memory usage: 164MB (peak: 308.02MB), time: 104.06s<br />某个PHP程序运行所需时间从195.99秒降低到104.06秒!</p>
<p>&hellip;&hellip;</p>

Copy after login

Generally speaking, disabling the garbage collector can improve PHP's operating efficiency by 70%.

Since PHP’s garbage collection is so unreliable, what was the original intention of its previous design?

Because in C/C++, memory management is a very troublesome thing. The use and release of memory require programmers to write programs to operate manually. If something is omitted, it may cause a waste of resources or even a memory leak. Therefore, in order to avoid this problem during PHP design, a garbage collector was introduced to automatically release the memory of useless objects.

It is worth mentioning that PHP will consume additional time when running the recycling algorithm. Although in smaller projects, this additional consumption is minimal, when running large projects, since multiple recycling threads are started at the same time, this consumption will have a great impact. The most intuitive manifestation is the program running The time got longer.

Disabling PHP’s garbage collection is the simplest and crudest way to improve the efficiency of program operation. This is just like if a leg or foot is injured, the easiest way is to amputate it.

As soon as the god-level code was released, the programmers on github were overjoyed:

Homm, who arrived first, expressed his surprise at this method of processing and did not understand why it was done, and objectively commented that this method of processing does not look good:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Then smileytechguy came and started teasing: "Well, there is no comment, let us disable the PHP kernel, and we will not explain why we do this."

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Then it started to get out of control:

Those who use soy sauce:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Those who complain and ridicule:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Just saying that PHP is the number one language in the world, there are versions in several countries. It is said that only a few pieces of code can increase efficiency by 70%. PHP is well deserved to be the number one language in the world:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

There are also cute ones:

Github is full of joy. PHP god-level code triggers complaints, githubphp god code_PHP tutorial

PHP’s garbage collection mechanism has become everyone’s joke. We also know that simply disabling PHP garbage collection cannot solve problems such as memory overflow. How PHP handles the contradiction between memory management and operating efficiency in the future will be a task. Something serious and long-lasting.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/927467.htmlTechArticleGithub’s many PHP god-level codes have caused complaints, githubphp god code The day before yesterday, Github’s PHP section suddenly appeared a paragraph that can The code that improves operating efficiency by 70% has aroused the vomit of many netizens around the world...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template