@@ -50,10 +50,10 @@ you can also set the current progress by calling the
5050
5151 If your platform doesn't support ANSI codes, updates to the progress
5252 bar are added as new lines. To prevent the output from being flooded,
53- adjust the
54- :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::setRedrawFrequency `
55- accordingly. By default, when using a `` max ``, the redraw frequency
56- is set to * 10% * of your ``max ``.
53+ you may adjust the update interval via these methods
54+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::preventRedrawFasterThan ` - write after each x seconds
55+ :method: ` Symfony \\ Component \\ Console \\ Helper \\ ProgressBar::setRedrawFrequency ` - write each x iteration
56+ By default, redraw frequency is ** 100ms ** or each ** 10% * * of your ``max ``.
5757
5858If you don't know the exact number of steps in advance, set it to a reasonable
5959value and then call the ``setMaxSteps() `` method to update it as needed::
@@ -289,17 +289,23 @@ to display it can be customized::
289289
290290.. caution ::
291291
292- For performance reasons, be careful if you set the total number of steps
293- to a high number. For example, if you're iterating over a large number of
294- items, consider setting the redraw frequency to a higher value by calling
295- :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::setRedrawFrequency `,
292+ By default, for performance reasons Symfony redraws screen every 100ms.
293+ In special cases, this can be too often and might hurt performance.
294+ In other cases, this can be opposite and it hurts UX.
295+ In either of these cases, consider tweaking redraw frequency by either of these methods:
296+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::preventRedrawFasterThan `
297+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::setRedrawFrequency `
298+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::forceRedrawSlowerThan `
296299 so it updates on only some iterations::
297300
298301 $progressBar = new ProgressBar($output, 50000);
299302 $progressBar->start();
300303
301- // update every 100 iterations
302- $progressBar->setRedrawFrequency(100);
304+ // redraw every 100 iterations or every 200ms (in case iterations go too slow)
305+ $progressBar->setRedrawFrequency(200);
306+ $progressBar->forceRedrawSlowerThan(0.2);
307+ // but don't redraw sooner than every 100ms (in case iterations go too fast)
308+ $progressBar->preventRedrawFasterThan(0.1);
303309
304310 $i = 0;
305311 while ($i++ < 50000) {
0 commit comments