Sebastian Raschka
last updated: 10/10/2014
In [ ]:
import pyprind
In [ ]:
n = 150000
bar = pyprind.ProgBar(n)
for i in range(n):
# do some computation
bar.update()
Note: the Percentage indicator is significantly slower due to background computation.
Thus, it is recommended for tasks with less iterations but longer computational time per iteration.
In [ ]:
n = 1500
perc = pyprind.ProgPercent(n)
for i in range(n):
# do some computation
perc.update()
Simply print()
the tracking object after the tracking has completed.
In [ ]:
n = 150000
bar = pyprind.ProgBar(n)
for i in range(n):
# do some computation
bar.update()
print(bar)
In [ ]:
n = 150000
bar = pyprind.ProgBar(n, monitor=True, title='Job_1')
for i in range(n):
# do some computation
bar.update()
# print report for future reference
print(bar)
monitor
(bool
): default False. Monitors CPU and memory usage if True
(requires 'psutil' package).
In [ ]:
n = 150000
bar = pyprind.ProgBar(n, monitor=True)
for i in range(n):
# do some computation
bar.update()
print(bar)
In [ ]:
n = 1500
perc = pyprind.ProgPercent(n, monitor=True)
for i in range(n):
# do some computation
perc.update()
print(perc)
title
(str
): default ''. A title for the progress bar
In [ ]:
n = 150000
bar = pyprind.ProgBar(n, title='My 1st Progress Bar')
for i in range(n):
# do some computation
bar.update()
In [ ]:
n = 1500
perc = pyprind.ProgPercent(n, title='My 1st Percent Tracker')
for i in range(n):
# do some computation
perc.update()
width
(int
): default 30. Sets the progress bar width in characters.
In [ ]:
n = 150000
bar = pyprind.ProgBar(n, width=10)
for i in range(n):
# do some computation
bar.update()
bar = pyprind.ProgBar(n, width=70)
for i in range(n):
# do some computation
bar.update()
stream
(int
): default 2. Takes 1 for stdout, 2 for stderr, or given stream object
In [ ]:
n = 150000
bar = pyprind.ProgBar(n, stream=1)
for i in range(n):
# do some computation
bar.update()
In [ ]:
bar = pyprind.ProgBar(n, stream=2)
for i in range(n):
# do some computation
bar.update()
In [ ]:
import sys
bar = pyprind.ProgBar(n, stream=sys.stdout)
for i in range(n):
# do some computation
bar.update()