LoginSignup
15
7

More than 3 years have passed since last update.

PHPで処理時間計測してみた

Last updated at Posted at 2018-04-07

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";
15
7
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
7