*概要 [#m0669a54]
-さくらのレンタルサーバと、さくらのVPSでGDの処理時間を比較する。
-結果、さくらのレンタルサーバの方が処理時間が短かった。
*実験内容 [#df6b2455]
-さくらのレンタルサーバと、さくらのVPSに実験用のPHPコードを置き、処理時間を比較する。
-実験に使用したPHP
--参考(というかそのまま) http://symfoware.blog68.fc2.com/blog-entry-1579.html
<?php
function do_resize() {
// 縦横、1600pxに収まるように縮小したい
$width = 1600;
$height = 1600;
//JPEGファイルを読み込む
$image = ImageCreateFromJPEG('sample.jpg');
// 元画像のファイルサイズを取得
$original_width = ImageSx($image);
$original_height = ImageSy($image);
//元画像の比率を計算し、高さを設定
$proportion = $original_width / $original_height;
$height = $width / $proportion;
//高さが幅より大きい場合は、高さを幅に合わせ、横幅を縮小
if($proportion < 1){
$height = $width;
$width = $width * $proportion;
}
$new_image = ImageCreateTrueColor($width, $height); // 画像作成
// 元画像から再サンプリング
ImageCopyResampled($new_image, $image,0,0,0,0,$width,$height,$original_width,$original_height);
// 保存
ImageJpeg( $new_image , 'result.jpg' , 80 );
}
$time_start = microtime(true);
for ($i = 0; $i < 100; $i++) {
do_resize();
}
$timelimit = microtime(true) - $time_start;
echo $timelimit . " seconds\n";
?>
-画像ファイル
#ref(sample.jpg,noimg)
*結果 [#m3b30184]
||さくらのレンタルサーバ スタンダード|さくらのVPS|さくらのVPS|
|||||
|ゾーン||石狩第1ゾーン|石狩第1ゾーン|
|メモリ|18GB|2 GB|32 GB|
|ディスク|100GB|SSD 50 GB|SSD 800 GB|
|CPU|Intel Xeon E312xx (Sandy Bridge)|仮想3コア|仮想10コア|
|OS|FreeBSD 9.1-RELEASE-p24 amd64|CentOS 6 x86_64|CentOS 6 x86_64|
|Apache|2.2.29|2.2.15|2.2.15|
|PHP|5.3.29|5.3.3|5.3.3|
|||||
|TEST1回目(秒)|89.42|103.30|110.01|
|TEST2回目(秒)|90.95|104.67|115.78|
|TEST3回目(秒)|88.45|106.59|115.69|
|TEST4回目(秒)|89.86|105.25|112.57|
|TEST5回目(秒)|89.84|103.35|100.50|
|平均|89.71|104.63|110.91|
*結論 [#kbd6e281]
-VPSより共用サーバの方が早い。
-仮想3コアと仮想10コアを比較すると、今回の結果では仮想3コアの方が早かった。
----
&size(12){Total:&counter(total); / Today:&counter(today); / Yesterday:&counter(yesterday);};