Skip to content

Commit 9a85c19

Browse files
committed
Merge pull request symfony#2588 from WouterJ/issue_2586
Documented setRedrawFrequenty()
2 parents 9766699 + e83b2ff commit 9a85c19

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

components/console/helpers/progresshelper.rst

+12-10
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,20 @@ To see other available options, check the API documentation for
5656

5757
.. caution::
5858

59-
For performance reasons, be careful to not set the total number of steps
60-
to a high number. For example, if you're iterating over a large number
61-
of items, consider a smaller "step" number that updates on only some
62-
iterations::
59+
For performance reasons, be careful if you set the total number of steps
60+
to a high number. For example, if you're iterating over a large number of
61+
items, consider setting the redraw frequency to a higher value by calling
62+
:method:`Symfony\\Component\\Console\\Helper\\ProgressHelper::setRedrawFrequency`,
63+
so it updates on only some iterations::
64+
65+
$progress->start($output, 50000);
66+
67+
// update every 100 iterations
68+
$progress->setRedrawFrequency(100);
6369

64-
$progress->start($output, 500);
6570
$i = 0;
6671
while ($i++ < 50000) {
6772
// ... do some work
6873

69-
// advance every 100 iterations
70-
if ($i % 100 == 0) {
71-
$progress->advance();
72-
}
73-
}
74+
$progress->advance();
75+
}

0 commit comments

Comments
 (0)