Several words speak, shocked: TP framework, php, html, php static page execution efficiency analysis and comparison!

Source: Internet
Author: User
Stunned by digital speech: efficiency analysis and comparison of TP framework, php, html, and php static pages !! & Nbsp; & nbsp; I plan to create a high-performance chat server Recently. I don't know how efficient Thinkphp3.2 is? That is to say, the efficiency of the framework is digital. We are shocked: analysis and comparison of the efficiency of TP framework, php, html, and php static page execution !!

I plan to create a high-performance chat server Recently. I don't know how efficient Thinkphp3.2 is? That is, how is the framework efficiency? So I tested it.
Task: Read 44 data records from the database.
1. Tp3.2 home-> controler-> IndexControler-> index ()
$ M = M ('login _ log ');
$ Login_log_list = $ m-> select ();
$ This-> assign ('login _ log_list ', $ login_log_list );
$ This-> display ('index ');
Template: index.html: Tag Display.

2. test2.php (core code :)
$ Result = mysql_query ('select * from login_log ');
While ($ item = mysql_fetch_assoc ($ result ))
32.16test2.html: the output result of test2.php.
4. test1.php: the suffix of test2.html is changed to php, and everything else remains unchanged.

Use the tool AB .exe to execute 1000 connections and 100 concurrent connections. Computer: Asus notebook cpu: u3400 6 GB memory. Win7. All programs are executed locally.
The result is as follows:

Results: http://chenrenqi.blog.sohu.com/303865454.html
The chart is not supported here. See the above link.

It can be seen that native PHP connects to the database, 11 times that of TP3.2. The time is mainly spent on file loading, class creation, and template parsing.
Static files are about 21 times the number of files connected to the database by php. It is about 4 times the php suffix.
You must know that, in actual work, a PHP file. That is, an http connection may require multiple database connections. the actual HTML speed may be more than 30 times faster than php, which is quite normal.

------ Solution ----------------------
Going back to your post, I said... the framework things need to instantiate a lot of useless things, but just implement a very small function, MVC framework-each time a page is refreshed, it must be instantiated from start to end, so... the pursuit of high performance · traditional process writing may be more refreshing · As for the development efficiency and maintenance problems · What the landlord needs to consider ··
------ Solution ----------------------
Thanks for sharing. However, PHP developers who have a little knowledge can understand this, let alone those who want to develop high-performance applications.
------ Solution ----------------------
I think this test is not fair. what about a mature Cache mechanism for the framework?
And where is the time spent on TP? Disk IO? Instantiated object write memory? Template rendering regular match?
These can all be done through caching.
------ Solution ----------------------
Haha, I think it is sharing spirit! Supported landlords
------ Solution ----------------------
A real programmer should all write native.

There is a framework because it can greatly accelerate development. Quickly build a project.

However, I don't think so. some websites, which are inconsistent with the framework logic, use native faster.

For example, TP is created for the forum. if I want to create a portal page, I need to complete the homepage effect similar to Sina.

At this time, you can be exhausted by using TP.
------ Solution ----------------------
I am happy with this look.

I belong to that 1%... most of the performance bottlenecks are on the disk I/O deployed in the MVC multi-file mode, which is hard to cope with high concurrency. if you want to enable the opcode cache, the test results will change a lot.
I'm very interested in which frame does the single page of the requests mentioned on the 16th floor belong...
In addition, the framework only provides the development mode and some common function encapsulation. Is there any difference between the business logic for forum or sina? Maybe I have never done it, but I really don't understand it. I hope the heroes will have time to make it easier.

Native php must be faster than the framework, but we can greatly reduce this gap through optimization methods.
If the page speed gap between and several seconds is more important than the development mode, we will use assembler for web ~

Although the younger brother has little experience, he also wants to refute xu's large scale. the cache is not self-confident, but to minimize the consumption of high-frequency repetitive work.
In a simple piece of news, write operations may only be performed once a lifetime, but read operations are performed every minute. you don't need to let the server software run the script every time, and you need something from the database, direct static files are much faster, as if static files can be optimized. the intermediate steps of the original hard disk-memory-Nic buffer can also be omitted.
For some recommendation news with complicated filtering conditions, it is not necessary to make database computing every time.
Of course, the excessive cache must be superfluous.


------ Solution ----------------------

In fact, I want to switch to another language for high concurrency. Efficiency also requires attention, but it is unnecessary to spray for efficiency.
------ Solution ----------------------
Yes. TP is suitable for forum communities and small websites with information. it is not suitable for large websites and is never expected to be a big project through TP.
------ Solution ----------------------
If you have time, you can test the yii efficiency.
------ Solution ----------------------
The framework is also used, but sometimes it is inconvenient to use it,
For example, after multi-condition query, how can we continue to obtain search conditions by page? TP is very troublesome here. it may not be possible to obtain multiple data records after several cycles!
------ Solution ----------------------
Node. js can be considered in the chat room.

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.