Skip to content

Get seconds per iteration in progress bar #184

@SanderLam

Description

@SanderLam

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions