Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elapsed_precise timer does not update if tick() called infrequently. #163

Closed
dan-da opened this issue Apr 7, 2020 · 1 comment
Closed

Comments

@dan-da
Copy link

dan-da commented Apr 7, 2020

For background/description, see #132

use indicatif::{MultiProgress, ProgressBar, TickTimeLimit, ProgressStyle, ProgressDrawTarget};
use rand::Rng;
use std::thread;
use std::time::Duration;



fn main() {
    let sty = ProgressStyle::default_bar()
        .template("{spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} ({bytes_per_sec}, {eta})  File")
        .progress_chars("##-");

    let mpb = MultiProgress::with_draw_target(ProgressDrawTarget::stderr_nohz());
    let pb1 = mpb.add(ProgressBar::new(30));
    let pb2 = mpb.add(ProgressBar::new(30));

    pb1.set_style(sty.clone());
    pb2.set_style(sty);

    // To use thread, uncomment this and comment mbp.tick() at bottom.
/*    
    let _ = thread::spawn(move || {
        loop {
            mpb.tick(TickTimeLimit::Indefinite);
            thread::sleep(Duration::from_millis(10));
        }
    });
*/

    let mut rng = rand::thread_rng();
    for _ in 0..50 {
        thread::sleep(Duration::from_millis(2000));
        pb1.set_position(rng.gen_range(0, 30));
        pb2.set_position(rng.gen_range(0, 30));
        
        mpb.tick(TickTimeLimit::Indefinite);
    }
}
@djc
Copy link
Collaborator

djc commented Feb 22, 2022

I don't think this is necessary with current main. If you still run into issues, please reopen.

@djc djc closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants