화니's 블로그

php5 벤치마크 본문

PHP

php5 벤치마크

곰탱이화니 2008. 6. 17. 18:24

PHP5 Benchmark

PHP: version 5.0.5
PC: Celeron 2.0Mhz / 512Mb

Creating int array[100 000]

PHP 5 Benchmark :: for vs while
code
[ms]
speed rate
faster
for($i=0;$i<10000;$i++) {..} 0.087
  99%
x1
while($i<10000) {..} 0.086
  100%
x1.01
compare with php 4

Reading int array[100 000]

PHP 5 Benchmark :: while vs foreach vs for
code
[ms]
speed rate
faster
foreach($arr1 as $vl) {..} 0.171
  95%
x1.95
while(list(,$vl = each($arr2)) {..} 0.335
  48%
x1
for($i=0;$i<10000;$i++) {..} 0.163
  100%
x2.05
compare with php 4

Reading apache log (16Mb)

PHP 5 Benchmark :: file vs file_get_content vs fread
code
[ms]
speed rate
faster
$a = file("t1.log"); 0.274
  44%
x1
$b = file_get_contents("t1.log"); 0.121
  100%
x2.26
.. $c = fread($hdl, $size); .. 0.141
  85%
x1.94
compare with php 4

Parse vars names [100 000]

PHP 5 Benchmark :: "test$i" vs "test".$i vs ‘test’.$i
code
[ms]
speed rate
faster
for() {$c = "test$i";}
0.354
  66%
x1
for() {$c = "test".$i;}
0.236
  100%
x1.5
for() {$c = ‘test’.$i;}
0.236
  100%
x1.5
compare with php 4

Parse and find text from apache log (32Mb)

PHP 5 Benchmark :: ereg vs preg_match
code
[ms]
speed rate
faster
eregi("2005:03:04",$txt); 3.521
  20%
x1
preg_match("/2005:03:04/im",$txt); 0.735
  100%
x4.7
compare with php 4

Split text apache log 200Kb (contain 2000 "-")

PHP 5 Benchmark :: split vs explode
code
[ms]
speed rate
faster
split("-",$txt); 1.573
  12%
x1
explode("-",$txt);
0.197
  100%
x8
compare with php 4

Count array size. $arr = int[100 000]

PHP 5 Benchmark :: count vs sizeof
code
[ms]
speed rate
faster
for($i=0;$i<count($arr);$i++) 0.276
  97%
x1
for($i=0;$i<sizeof($arr);$i++) 0.268
  100%
x1.02
compare with php 4

Create object by Ref (loop 100 000)

PHP 5 Benchmark :: with ref vs without ref
code
[ms]
speed rate
faster
(…) {$j = & new TestClass();}
1.180
  100%
x1
(…) {$j = new TestClass(); } 1.291
  91%
x1.09
compare with php 4

Random number generator (loop 100 000)

PHP 5 Benchmark :: srand vs mt_srand
code
[ms]
speed rate
faster
(…) { srand(); } 0.193
  19%
x1
(…) { mt_srand(); } 0.989
  100%
x5.12
compare with php 4

Calculate hash (loop 100 000)

PHP 5 Benchmark :: srand vs mt_srand
code
[ms]
speed rate
faster
(…) { md5($i."byster.net".$i); } 1.365
  100%
x1
(…) { sha1($i."byster.net".$i);} 1.662
  82%
x1.2
compare with php 4

php벤치마크를 해놓은 곳이 있네요 ^^;

http://byster.net/?page_id=48


이외에도 mysql, apache등의 벤치마크도 있습니다.

Comments