#progress #time #remaining #process #estimate #estimating #eta

chug

Estimate time remaining for a long-running process

2 stable releases

1.1.0 Jan 10, 2023
1.0.0 Dec 30, 2022

#3 in #estimating

Download history 25/week @ 2023-12-06 43/week @ 2023-12-27 2/week @ 2024-01-03 2/week @ 2024-01-24 33/week @ 2024-01-31 1/week @ 2024-02-14 52/week @ 2024-02-21 59/week @ 2024-02-28 3/week @ 2024-03-06 5/week @ 2024-03-13

120 downloads per month

MIT license

8KB
152 lines

Chug

Estimate the time remaining for a long-running process.

Installation

cargo add chug

Usage

See examples/tick.rs for a simple example.

License

MIT


lib.rs:

A library for estimating the time remaining until a task is completed.

Example

use chug::Chug;

let mut chug = Chug::new(10, 100);

for _ in 0..100 {
    let formatted_eta = match chug.eta() {
        Some(eta) => {
            let eta_secs = eta.as_secs();
            let eta_millis = eta.subsec_millis();
            format!("ETA: {}.{:03}", eta_secs, eta_millis)
        }
        None => "ETA: None".to_string(),
    };
    println!("{}", formatted_eta);

    // Do some work...

    chug.tick();
}

No runtime deps