Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Locating slow code in Laravel

Is there a built-in way to benchmark and track down slow code in Laravel?

Or is it more effective to just do a cachegrind out?

Every page on one of the sites I just built is taking 1-2 seconds to load regardless of how simple the page is.

like image 698
eComEvo Avatar asked Jan 23 '26 02:01

eComEvo


2 Answers

The laravel-debugbar package is a really great tool to figure out what is causing your slow load times.

It can be added by adding:

"barryvdh/laravel-debugbar": "dev-master",

To your composer.josn file then:

'Barryvdh\Debugbar\ServiceProvider',

as a ServiceProvider in app/config/app.php

Then you can publish it using artisan (only to the environment you want to run tests on).

php artisan debugbar:publish

You can find better instructions on their github page here.

Thank you for the suggestion! Here are a few screenshots of the debugbar:

enter image description here Display of queries that were run

like image 133
Elliot Fehr Avatar answered Jan 25 '26 16:01

Elliot Fehr


Another solution which I use is Clockwork. Give it a try, I think you'll like it.

https://github.com/itsgoingd/clockwork

like image 34
Gareth Daine Avatar answered Jan 25 '26 15:01

Gareth Daine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!