question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get seconds per iteration in progress bar

See original GitHub issue

Hi there!

Love the package and the customisations so far!

I have a process that takes around 2 seconds per iteration. and would like to see something like 2.01s/it. The tqdm package automatically switches between iterations per second and seconds per iteration, depending on which one there are more of per second.

For example:

import time
from alive_progress import alive_bar

with alive_bar(3) as bar:
    for i in range(3):
        time.sleep(2)
        bar()

from tqdm import tqdm

for i in tqdm(range(3)):
    time.sleep(2)
    bar()

Output:

alive-progress:
|█████████████▍                          | ▆▄▂ 1/3 [33%] in 3s (0.3/s, eta: 4s)

tqdm:
 33%|███████               | 1/3 [00:02<00:04,  2.01s/it]

I’ve seen the customisation of the stats option in the alive_bar, but don’t see a way how to change the {rate} to {1/rate}

stats (bool|str): [True] configures the stats widget (123.4/s, eta: 12s)
↳ send a string with {rate} and {eta} to customize it

Thanks!

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
TheTechRobocommented, Aug 26, 2022

I don’t really mind either way, but in some cases it might be better to show the per-iteration speed. It’s easier to interpret “each one takes about 17 minutes” than “3.5 ones per hour” IMO. I think it should be configurable.

2reactions
TheTechRobocommented, Aug 26, 2022

I’m not sure whether this use-case warrants support in alive-progress itself, since the majority of the time one should be monitoring processes in the ms or µs or even ns ranges… This means k/s or even M/s.

Really? I use mine for long-running, slow iterations, because of alive-progress’s amazingness. You don’t IMO only need to use a progress bar with short iterations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to print iterations per second? - python
Here, I'm keeping a list of durations of last 10 iterations over which I can then use to get the average number of...
Read more >
How to show iterations per second (like tdqm) #253
I think you are looking for the AdaptiveTransferSpeed: https://progressbar-2.readthedocs.io/en/latest/progressbar.widgets.html#progressbar.widgets.
Read more >
Monitoring Iteration Progress with tqdm | by Peter Haferl
The way it works is by wrapping the iterable with the tqdm method and viola, a fully functional progress bar appears to save...
Read more >
Training models with a progress bar - (Machine) Learning log.
You can see the nice output with 9.90it/s meaning an average speed of 9.90 iterations per second.
Read more >
Training models with a progress bar | by Adam Oudad
tqdm is a Python library for adding progress bar. ... the nice output with 9.90it/s meaning an average speed of 9.90 iterations per...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found