console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.46k stars 243 forks source link

Feature Req.: Human readable `per_sec` rate #637

Open amandasaurus opened 8 months ago

amandasaurus commented 8 months ago

I am using indicatif to process lots of data, and it's great. My programme does hundreds of thousands to millions of iterations of second. The {per_sec} template will show me the rate to 4 decimal places (e.g. 120,399,714.0565/s). That's too many numbers.

Can we get a per_sec_human template variable which will print something like 120 M/s in this case?

djc commented 8 months ago

If you submit a PR I'd be okay with reviewing/merging it. Arguably the human formatting should have been more like an orthogonal filter from the start...

tgross35 commented 4 months ago

Could this be something like a :short suffix instead, to print any number with k/M/G prefixes? I would love it for other options, so {pos:short}/{len:short} ({per_sec:short}) could print 143M/4G (1.0M/s) (currently 143288000/4294967295 (1,008,174.0894/s)).

djc commented 4 months ago

@tgross35 something like that sounds interesting... Maybe display 3 significant digits, so it could be 143 or 7.21k or 39.4M?