ログイン



PHP5.4.0RC7の実効速度

火曜日, 2月 7th, 2012 by

PHP5.4は速い。という情報が出ているので実際に測定してみた。

実行環境

EC2でc1.mediumを使って実験した。OSは32ビットで、PHPはコマンドライン(CLI)モードを使った。

ハードウェア

AmazonEC2 c1.mediumを使用。

CPUは以下のとおり。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5506  @ 2.13GHz
stepping        : 5
cpu MHz         : 2133.306
cache size      : 4096 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht nx constant_tsc nonstop_tsc aperfmperf pni ssse3 sse4_1 sse4_2 popcnt hypervisor
bogomips        : 4266.61
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5506  @ 2.13GHz
stepping        : 5
cpu MHz         : 2133.306
cache size      : 4096 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht nx constant_tsc nonstop_tsc aperfmperf pni ssse3 sse4_1 sse4_2 popcnt hypervisor
bogomips        : 4266.61
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

測定してみた

ループ1000万回に掛かる時間を10回測定
ソースコード

1
2
3
4
5
6
<?php
for($i = 0; $i < 10; $i++){
$start = microtime(true);
for($j = 0; $j < 10000000; $j++);
printf("%.5f\n", (microtime(true)-$start));
}

実行結果: PHP5.3.10
平均616ms

1
2
3
4
5
6
7
8
9
10
11
[root@ip-10-150-231-174 ec2-user]# php-5.3.10/sapi/cli/php bench.php
0.61347
0.61123
0.61310
0.61214
0.61255
0.61618
0.61851
0.61899
0.62268
0.61765

実行結果: PHP5.4.0RC7
平均:408ms PHP5.3.10比で1.51倍の実行速度

1
2
3
4
5
6
7
8
9
10
11
[root@ip-10-150-231-174 ec2-user]# php-5.4.0/sapi/cli/php bench.php
0.40750
0.40780
0.40873
0.40742
0.40734
0.40746
0.40784
0.40703
0.40780
0.40723

まとめ

掲載した以外にも何パターンかのベンチマークをとってみたが、いずれの測定結果でも実効性能は大幅に向上していた。既にRCまで開発が進んでいるので、正式版でもほぼ同じような性能特性になるだろう。性能面だけをとってみても、PHP5.4は価値のあるリリースになりそうだ。

Leave a Reply