Crates.io | speedometer |
lib.rs | speedometer |
version | 0.2.2 |
source | src |
created_at | 2018-04-18 11:58:59.376576 |
updated_at | 2018-04-18 19:15:43.914888 |
description | Measure throughput per second. |
homepage | |
repository | https://github.com/datrs/speedometer |
max_upload_size | |
id | 61212 |
size | 27,941 |
Measure throughput per second. Adapted from mafintosh/speedometer.
It's often useful to figure out the average over a sliding timeframe. For example: "how many bytes did we receive on average over the last 5 seconds?". Or anything similar. This module allows you to do so in synchronous code.
extern crate speedometer;
use speedometer::Speedometer;
use std::time::Duration;
let window_size = Duration::from_secs(5); // default is 5 second window size
let mut meter = Speedometer::new(window_size);
meter.entry(10);
println!("{:?} bytes/second!", meter.measure().unwrap());
$ cargo add speedometer
MIT OR Apache-2.0