سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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

https://github.com/itsgoingd/clockwork

Right, clockwork is good, it gives all required information. You can use browser extension https://github.com/itsgoingd/clockwork-chrome or cli application https://github.com/ptrofimov/clockwork-cli

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top