Skip to content

Commit 097b3a3

Browse files
committed
Reword
1 parent 30736ad commit 097b3a3

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

components/console/helpers/progressbar.rst

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ 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-
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.
5762

5863
If you don't know the exact number of steps in advance, set it to a reasonable
5964
value and then call the ``setMaxSteps()`` method to update it as needed::
@@ -289,22 +294,19 @@ to display it can be customized::
289294

290295
.. caution::
291296

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:
296299
:method:`Symfony\\Component\\Console\\Helper\\ProgressBar::preventRedrawFasterThan`
297300
: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`::
300302

301303
$progressBar = new ProgressBar($output, 50000);
302304
$progressBar->start();
303305

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);
306309
$progressBar->forceRedrawSlowerThan(0.2);
307-
// but don't redraw sooner than every 100ms (in case iterations go too fast)
308310
$progressBar->preventRedrawFasterThan(0.1);
309311

310312
$i = 0;
@@ -314,6 +316,11 @@ to display it can be customized::
314316
$progressBar->advance();
315317
}
316318

319+
.. versionadded::
320+
321+
The ``forceRedrawSlowerThan`` and ``preventRedrawFasterThan()`` methods
322+
were introduced in Symfony 4.4.
323+
317324
Custom Placeholders
318325
~~~~~~~~~~~~~~~~~~~
319326

0 commit comments

Comments
 (0)