@@ -50,10 +50,15 @@ you can also set the current progress by calling the
50
50
51
51
If your platform doesn't support ANSI codes, updates to the progress
52
52
bar are added as new lines. To prevent the output from being flooded,
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 ``.
53
+ use the method :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::preventRedrawFasterThan `
54
+ (it writes to the output after every N seconds) and the method
55
+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::setRedrawFrequency `
56
+ (it writes to the output every N iterations). By default, redraw frequency is
57
+ **100ms ** or **10% ** of your ``max ``.
58
+
59
+ .. versionadded ::
60
+
61
+ The ``preventRedrawFasterThan() `` method was introduced in Symfony 4.4.
57
62
58
63
If you don't know the exact number of steps in advance, set it to a reasonable
59
64
value and then call the ``setMaxSteps() `` method to update it as needed::
@@ -289,22 +294,19 @@ to display it can be customized::
289
294
290
295
.. caution ::
291
296
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:
297
+ For performance reasons, Symfony redraws screen every 100ms. If this is too
298
+ fast or to slow for your application, use these methods:
296
299
:method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::preventRedrawFasterThan `
297
300
:method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::setRedrawFrequency `
298
- :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::forceRedrawSlowerThan `
299
- so it updates on only some iterations::
301
+ :method: `Symfony\\ Component\\ Console\\ Helper\\ ProgressBar::forceRedrawSlowerThan `::
300
302
301
303
$progressBar = new ProgressBar($output, 50000);
302
304
$progressBar->start();
303
305
304
- // redraw every 100 iterations or every 200ms (in case iterations go too slow)
305
- $progressBar->setRedrawFrequency(200);
306
+ // this redraws the screen every 100 iterations, but sets additional limits:
307
+ // don't redraw slower than 100ms (0.1) or faster than 200ms (0.2)
308
+ $progressBar->setRedrawFrequency(100);
306
309
$progressBar->forceRedrawSlowerThan(0.2);
307
- // but don't redraw sooner than every 100ms (in case iterations go too fast)
308
310
$progressBar->preventRedrawFasterThan(0.1);
309
311
310
312
$i = 0;
@@ -314,6 +316,11 @@ to display it can be customized::
314
316
$progressBar->advance();
315
317
}
316
318
319
+ .. versionadded ::
320
+
321
+ The ``forceRedrawSlowerThan `` and ``preventRedrawFasterThan() `` methods
322
+ were introduced in Symfony 4.4.
323
+
317
324
Custom Placeholders
318
325
~~~~~~~~~~~~~~~~~~~
319
326
0 commit comments