20
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel Debugbarで簡易速度計測

Last updated at Posted at 2019-11-12

Laravelをお使いの皆さんにはおなじみLaravel Debugabrですが簡易的な速度計測ができることをご存知でしょうか。
xhprofやblackfireを使えというマサカリは受け付けません
明らかに処理が遅そうだが確証がないな〜、簡易的でいいから計測したいな〜というときに便利です。

start_measure('このへん重そう');
// ここに怪しい処理がある
stop_measure('このへん重そう');

ヘルパー関数が用意されているのでこんな感じで怪しい処理にstart_measurestop_measureを挟みましょう。
始まりと終わりは同じ文字列を入れましょう。

いつものDebugbarのTimelineで以下のように見ることができます。
2019-11-12 17.24.20 localhost adc9fd177940.png
(View数,Query数はひみつ)
はい、全然違いましたね。

start_measure('このへん重そう');
// ここに怪しい処理がある
stop_measure('このへん重そう');

start_measure('じゃあこっちか?');
// あんまり怪しくないと思ってた処理
stop_measure('じゃあこっちか?');

2019-11-12 17.27.52 localhost 471cc4561bf1.png

無事遅い箇所が特定できました。
他にもログを出す機能も付いてるので活用してみてください。
おしまい

20
8
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
20
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?