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

[5.8] Add runtime for each seeder and overall seeders runtime to output #29193

Closed
wants to merge 10 commits into from

Conversation

chelout
Copy link

@chelout chelout commented Jul 16, 2019

This PR was inspired by @jwpage #29149

This adds the runtime for each individual seeder and overall seeders runtime to the output of the artisan db:seed command, including artisan migrate --seed. I also changed a bit output format to be more consistent with migrations. I find this useful to get an idea of how long each seeder will take to run and in general. Tired to run time php artisan migrate:fresh --seed

Example output:
Снимок экрана 2019-07-16 в 23 57 36

Copy link
Contributor

@browner12 browner12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the idea! I definitely have some long running seeders, would be nice to see this info.

Copy link
Contributor

@seriquynh seriquynh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create helpers (or traits) to reduce duplicate code?

$startTime = microtime(true);

// Do some stuff

$runTime = round(microtime(true) - $startTime, 2);
$runTime = $this->duration(function () {
    // Do some stuff
});

@chelout
Copy link
Author

chelout commented Jul 18, 2019

@XuanQuynh don't think trait is good idea, but helper looks nice!

Added a duration helper in latest commit.

@antonkomarev
Copy link
Contributor

I don't think we need to add more global helpers.

@taylorotwell
Copy link
Member

I'm not sure I would make a global helper. I would make some sort of Stopwatch support class if I was going to do this at all.

@driesvints driesvints changed the title Add runtime for each seeder and overall seeders runtime to output [5.8] Add runtime for each seeder and overall seeders runtime to output Jul 18, 2019
@driesvints
Copy link
Member

driesvints commented Jul 18, 2019

Let's please indeed not make a global helper. Stopwatch class sounds good 👍

@chelout
Copy link
Author

chelout commented Jul 18, 2019

We have already such class in laravel/horizon
We can move this implementation to framework, @driesvints @taylorotwell what do you think?

@antonkomarev
Copy link
Contributor

That would be even better.

@chelout
Copy link
Author

chelout commented Jul 19, 2019

Added Stopwatch class.

@chelout
Copy link
Author

chelout commented Jul 19, 2019

@driesvints hope, i got you right.

@taylorotwell
Copy link
Member

Your stopwatch class says it returns time in milliseconds. Your console output lists time in seconds.

@chelout
Copy link
Author

chelout commented Jul 29, 2019

@taylorotwell fixed that.

@taylorotwell
Copy link
Member

The stopwatch SHOULD return time in milliseconds. Returning seconds isn't going to be useful in the vast majority of situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants