Based on the reasons why PHP is better than other CGI

Source: Internet
Author: User
Tags min
Q: Why is PHP better than other CGI? Is there any specific data that can prove the efficiency of PHP execution and other CGI execution? Now my company uses C to write CGI. Will it be better if I change to PHP? Without a strong and powerful basis, I can't convince the above people to turn me into PHP...
A:
I think there are three points for "good"
First, the program is fast to run.
Second, the execution efficiency is strong when there is a large number of accesses.
Third, program development is fast and easy to maintain.
Although php is not necessarily the best among the three points
The following is a comparison between C, PHP, and Perl in terms of speed.
I use the following formula to test
$ S = 1.0;
For ($ I = 1; $ I <= 10; $ I ++ ){
For ($ j = 1; $ j <= 10; $ j ++ ){
$ S = $ s * 1.0005;
$ S = $ s/1.0004;
};
};
Print $ s;
?>
Use AB-n 10000-c 20 http: // mycgi
Test and result
The C language took 37.511 seconds.
PHP3 takes 45.393 seconds
PERL took 68.418 seconds
It seems that C is the fastest. That's right, but the result is not big with PHP3.
.
Perl slowest
Test data:
========================================================== ======
C language
========================================================== ======
Document Path :/~ Evan/test/gcc. cgi
Document Length: 19 bytes
Concurrency Level: 20
Time taken for tests: 37.511 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1750000 bytes
HTML transferred: 190000 bytes
Requests per second: 266.59
Transfer rate: 46.65 kb/s converted Ed
Connnection Times (MS)
Min avg max
Connect: 0 30 3001
Processing: 4 40 69
Total: 4 70 3070
PHP3
========================================================== ======
Document Path :/~ Evan/test/php3.php3
Document Length: 15 bytes
Concurrency Level: 20
Time taken for tests: 45.393 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1710000 bytes
HTML transferred: 150000 bytes
Requests per second: 220.30
Transfer rate: 37.67 kb/s converted Ed
Connnection Times (MS)
Min avg max
Connect: 0 34 3039
Processing: 6 53 183

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.