Closed triwahyuu closed 3 years ago
rate is calculated during formating, so there's no way to access it independently. I can look at adding a field for inverted rate. For now, you can calculate it and pass it as an argument.
import enlighten
import time
bar_format = u'{desc}{desc_pad} {percentage:3.0f}%|{bar}| ' + \
u'{count:{len_total}d}/{total:d} ' + \
u'[{elapsed}<{eta}, {seconds_per_file:.2f}{unit_pad}s/{unit}]'
manager = enlighten.get_manager(bar_format=bar_format)
bar = manager.counter(total=100, desc='Loading', unit='files', seconds_per_file=0)
bar.refresh()
for num in range(100):
time.sleep(2.3) # Simulate work
seconds_per_file = bar.elapsed / (bar.count + 1)
bar.update(seconds_per_file=seconds_per_file)
will it be possible to add this feature by default? I find it quite useful
anyway, thank you for the answer.
It seems useful enough and has a relatively low cost that I think we can add it as a built-in field. I'm leaning towards calling it "interval". There are some other changes I'm working on now, but I'll try to add it once those are done.
thanks, really appreciate it.
I have a long lived process that never run 1s each iteration, so I wanted to display it as
{1/rate} s/iteration
, is there a way to get the inverted value ofrate
(1/rate
)?