PHPで処理速度を計算するには
「処理速度を計測したいコード」を下記のコードで挟んであげる。
※ microtime()
の引数にはtrueを入れてあげないと秒にならない。
$st = microtime(true);
// 処理
$now = microtime(true);
echo '○○の処理時間:'.($now - $st)."秒<br>\n";
複数処理の場合
$st_a = microtime(true);
// 処理
$st_b = microtime(true);
// 処理b
$end_b = microtime(true);
$end_a = microtime(true);
echo '処理aの処理時間:'.($end_a - $st_a)."秒<br>\n";
echo '処理bの処理時間:'.($end_b - $st_b)."秒<br>\n";