I work on several artisan commands that do something in a loop over a different quantity of items. Sometimes it's 30
items, sometimes it's 800k
items, sometimes 20k
.
Everything works but sometimes the output blinks. I know why - due to the too frequent refresh.
$progress = $this->output->createProgressBar($this->countSyncRowsCleaned);
I came up with determining the refresh rate somehow dynamically based on the volume of records to loop through. So instead of hardcoding:
$progress->setRedrawFrequency(50);
I do:
$progress->setRedrawFrequency(max(1, floor($this->countSyncRowsCleaned / 1000)));
Sometimes 50
is great, sometimes it's still to frequent.
What would be a good math formula to set reasonable redraw frequency for a huge spread of integers? Sometimes several records, sometimes over a million.
Thanks for any hints.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire