Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new models collector #947

Merged
merged 1 commit into from Jul 29, 2019

Conversation

@reinink
Copy link
Contributor

commented Jul 29, 2019

This PR adds a new "models" collector. It essentially listens for eloquent.retrieved events, and totals them by model type. This provides a super helpful insight into how many Eloquent models are being generated for a request...something that can have a huge impact on performance.

At first I had it where you could click on each model type to view all the loaded models. However, after chatting with @barryvdh, we decided it was probably better to just show the totals, to keep things snappy.

image

By default this metric is disabled, but I could honestly see this being enabled by default in the future, if folks find it as useful as I do.

@barryvdh barryvdh merged commit bda348f into barryvdh:master Jul 29, 2019

@barryvdh

This comment has been minimized.

Copy link
Owner

commented Jul 29, 2019

Looks good, gonna try this out for a bit :)

@reinink

This comment has been minimized.

Copy link
Contributor Author

commented Jul 29, 2019

Awesome! I'll do the same. Thanks Barry! ❤️

public function __construct(Dispatcher $events)
{
parent::__construct('models');
$this->setDataFormatter(new SimpleFormatter());

This comment has been minimized.

Copy link
@juancho48

juancho48 Jul 29, 2019

is this being used somewhere else?

This comment has been minimized.

Copy link
@reinink

reinink Jul 29, 2019

Author Contributor

Yes...I stole it from other collectors. For example:

public function __construct(Gate $gate)
{
parent::__construct('gate');
$this->setDataFormatter(new SimpleFormatter());

@kbussche

This comment has been minimized.

Copy link

commented Aug 7, 2019

Any ETA on when this will get tagged (3.2.5) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.