Shanghai WTO Forum

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3570|回复: 0

基于什么样的理由 PHP 比其它 CGI 好呢?

[复制链接]
发表于 2007-12-3 17:53:04 | 显示全部楼层 |阅读模式
Q:基于什么样的理由 PHP 比其它 CGI 好呢?有没有比较具体的数据可以证明 PHP 执行与其它 CGI 执行的效率好 ? 现在我的公司是用 C 来写 CGI 的,如果换成 PHP,会不会比较好呢 ?没有强而有力的依据的话,我就没办法说服上面的人让我转成 PHP 了... <></P><>A: <BR>我认为"好" 要有三点 <BR>第一: 写出来的程式的执行速度快. <BR>第二: 遇到有大量存取时的执行效能强. <BR>第三: 程式开发的时间快,易维护。 <BR>php在这三点中,虽都不一定是最好的,但也都在前茅 </P><>以下是C,PHP和Perl在速度方面的比较 <BR>我用下面的算式测试 <BR>$s=1.0; <BR>for ($i=1;$i<=10;$i++) { <BR>for ($j=1;$j<=10;$j++) { <BR>$s=$s*1.0005; <BR>$s=$s/1.0004; <BR>}; <BR>}; <BR>print $s; <BR>?> <BR>然后用ab -n 10000 -c 20 http://mycgi <BR>测试,结果 <BR>C语言用了 37.511 秒 <BR>HP3用了 45.393 秒 <BR>ERL用了 68.418 秒 </P><>看起是C 最快没错,不过,和PHP3的结果没有太大 <BR>的差距。 <BR>erl最慢 </P><>以下为测试数据 <BR>============================================== <BR>C 语言 <BR>============================================== </P><>Document Path: /~evan/test/gcc.cgi <BR>Document Length: 19 bytes </P><>Concurrency Level: 20 <BR>Time taken for tests: 37.511 seconds <BR>Complete requests: 10000 <BR>Failed requests: 0 <BR>Total transferred: 1750000 bytes <BR>HTML transferred: 190000 bytes <BR>Requests per second: 266.59 <BR>Transfer rate: 46.65 kb/s received </P><P>Connnection Times (ms) <BR>min avg max <BR>Connect: 0 30 3001 <BR>Processing: 4 40 69 <BR>Total: 4 70 3070 </P><P>PHP3 <BR>============================================== <BR>Document Path: /~evan/test/php3.php3 <BR>Document Length: 15 bytes </P><P>Concurrency Level: 20 <BR>Time taken for tests: 45.393 seconds <BR>Complete requests: 10000 <BR>Failed requests: 0 <BR>Total transferred: 1710000 bytes <BR>HTML transferred: 150000 bytes <BR>Requests per second: 220.30 <BR>Transfer rate: 37.67 kb/s received </P><P>Connnection Times (ms) <BR>min avg max <BR>Connect: 0 34 3039 <BR>Processing: 6 53 183 <BR>Total: 6 87 3222 </P><P><BR>PERL <BR>============================================== <BR>Document Path: /~evan/test/perl.cgi <BR>Document Length: 17 bytes </P><P>Concurrency Level: 20 <BR>Time taken for tests: 68.418 seconds <BR>Complete requests: 10000 <BR>Failed requests: 0 <BR>Total transferred: 1730173 bytes <BR>HTML transferred: 170017 bytes <BR>Requests per second: 146.16 <BR>Transfer rate: 25.29 kb/s received </P><P>Connnection Times (ms) <BR>min avg max <BR>Connect: 0 22 3005 <BR>Processing: 9 112 323 <BR>Total: 9 134 3328 </P>
您需要登录后才可以回帖 登录 | 注册

本版积分规则


QQ|Archiver|mobile|The little black house|Shanghai WTO Net ( 沪ICP备10034107号-3 )

GMT+8, 2024-12-22 18:38

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表