0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【PHP】処理の計測時間をデバッグするサンプルコード

Posted at

パフォーマンス改善をしたいときに、処理にどれくらい時間がかかっているかをデバッグしたいときがあると思う。

そんなときに便利なサンプルコードは以下になります。

// 処理開始時のタイムスタンプを記録
$startTime = microtime(true);

// 処理内容(省略)

// 処理時間を計測
$executionTime = microtime(true) - $startTime;

print_r('Execution Time: {$executionTime} seconds');

Laravelであれば、以下のようにデバッグをすると良いでしょう。

\Log::debug('Execution Time: {$executionTime} seconds');

以上、処理の計測時間をデバッグするサンプルコードでした。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?