Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Wednesday, June 1, 2011

punbb vs phpbb3

누가 더 빠를까?



궁금해서 LG NAS N1T1 에서 테스트를 해봤다.

간단한 사양은

128MB RAM 에 1GHz ARM CPU를 갖고 있다. RAM이 너무 적어서 혹시 bottleneck이 되지 않을까 싶었지만 오히려 CPU가 bottleneck이였다.



아무튼 테스트 결과는 다음과 같다.

각각 게시물 하나씩 등록하고 그 게시물을 공격적으로 읽는것으로 테스트했다.

테스트에 이용한 프로그램은 ab 이다.



사용예)   ab -n 500 -c 10 http://example.com/



punBB

punbb/viewtopic.php?pid=7#p7



Server Software:        Apache/2.2.14
Server Hostname:        example.lgnas.com
Server Port:            80

Document Path:          /punbb/viewtopic.php?pid=7#p7
Document Length:        9744 bytes

Concurrency Level:      10
Time taken for tests:   59.885488 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      5063500 bytes
HTML transferred:       4872000 bytes
Requests per second:    8.35 [#/sec] (mean)
Time per request:       1197.710 [ms] (mean)
Time per request:       119.771 [ms] (mean, across all concurrent requests)
Transfer rate:          82.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.6      0      57
Processing:   538 1192 147.4   1186    2053
Waiting:      531 1103 143.4   1097    1945
Total:        538 1192 147.4   1186    2053

Percentage of the requests served within a certain time (ms)
  50%   1186
  66%   1240
  75%   1272
  80%   1299
  90%   1342
  95%   1414
  98%   1558
  99%   1717
 100%   2053 (longest request)





phpBB3



Server Software:        Apache/2.2.14
Server Hostname:        example.lgnas.com
Server Port:            80

Document Path:          /phpBB3/viewtopic.php?f=2&t=1
Document Length:        11480 bytes

Concurrency Level:      10
Time taken for tests:   99.27929 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      6084000 bytes
HTML transferred:       5740000 bytes
Requests per second:    5.05 [#/sec] (mean)
Time per request:       1980.559 [ms] (mean)
Time per request:       198.056 [ms] (mean, across all concurrent requests)
Transfer rate:          59.99 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   999 1972 223.2   1957    3125
Waiting:      957 1722 205.4   1701    2719
Total:        999 1972 223.2   1957    3125

Percentage of the requests served within a certain time (ms)
  50%   1957
  66%   2048
  75%   2101
  80%   2133
  90%   2259
  95%   2322
  98%   2497
  99%   2606
 100%   3125 (longest request)





결과적으로 punBB가 더 빨랐다.

유의미한 차이를 보인 다른 부분은 부하가 걸렸을 때의 apache 서버의 크기였다. punbb의 경우 8MB를 왔다갔다 했던 반면에 phpBB3의 경우 13MB까지 상승하는 경우가 많았다.



단순히 이정도의 차이라면 phpBB3를 사용하는 것도 크게 문제가 될 것 같지는 않다.

웹 페이지 로딩 시간을 구해보자. 웹 페이지 속도 측정

Measuring PHP page load time

You probably wonder how much time is needed for your PHP page to load. It can be crucial for your web server if your php scripts load slow and take most of the CPU and RAM resources. It is also a good idea to measure  parts of your PHP code which can cause delays such as for/while cycles, writing/reading to/from files or MySQL database.
Using microtime() PHP function you will know exactly how much time is needed for your PHP code to be executed. Follow the steps below to put the PHP code on your web page:
Put the following code at the very top of your PHP page (if you measure the time needed for particular part of the code put this right before that PHP code part)
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>
The following code has to be put at the very end of the web page (or the end of the PHP code part)

$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo 'Page generated in '.$total_time.' seconds.'."\n";
?>
Now, when you access your web page you will know the time needed for it to execute. This is an example output of what you are going to see:
Page generated in 0.0031 seconds.


좀더 편리하게 사용하기 위해서 함수 형태로 만들어 보았다.


<?php

function current_time()
{
        $time = microtime();
        $time = explode(' ', $time);
        $time = $time[1] + $time[0];
        return $time;
}
function get_elapsed_time($start, $end)
{
$total_time = round(($end - $start), 4);
        return $total_time;
}
?>