-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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
});
@XuanQuynh don't think trait is good idea, but helper looks nice! Added a duration helper in latest commit. |
I don't think we need to add more global helpers. |
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. |
Let's please indeed not make a global helper. Stopwatch class sounds good 👍 |
We have already such class in laravel/horizon |
That would be even better. |
Added Stopwatch class. |
@driesvints hope, i got you right. |
Your stopwatch class says it returns time in milliseconds. Your console output lists time in seconds. |
@taylorotwell fixed that. |
The stopwatch SHOULD return time in milliseconds. Returning seconds isn't going to be useful in the vast majority of situations. |
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:
