1 个不稳定版本
使用旧的 Rust 2015
| 0.1.0 | 2018年10月15日 |
|---|
#550 in 机器学习
862 每月下载量
用于 2 crates
16KB
264 行
Rust crate 提供了 RunningAverage 和 RealTimeRunningAverage 类型,允许使用固定内存计算指定时间窗口宽度的运行平均值。
RunningAverage 类型可用于处理时间序列数据流,而 RealTimeRunningAverage 类型则适用于实时发生的事件测量。
例如,可以使用 RealTimeRunningAverage 通过插入已传输的字节数来测量下载吞吐量。
use running_average::RealTimeRunningAverage;
// By default use 8 second window with 16 accumulators
let mut tw = RealTimeRunningAverage::default();
// Connect and start downloading
// Got 2KB of data
tw.insert(2000);
// Waiting for more data
// Got 1KB of data
tw.insert(1000);
// Print average transfer for last 8 seconds
println!("{}", tw.measurement());
lib.rs:
RunningAverage 和 RealTimeRunningAverage 类型允许使用固定内存计算指定时间窗口宽度的运行平均值。
RunningAverage 类型可用于处理时间序列数据流,而 RealTimeRunningAverage 类型则适用于实时发生的事件测量。
例如,可以使用 RealTimeRunningAverage 通过插入已传输的字节数来测量下载吞吐量。
use running_average::RealTimeRunningAverage;
// By default use 8 second window with 16 accumulators
let mut tw = RealTimeRunningAverage::default();
// Connect and start downloading
// Got 2KB of data
tw.insert(2000);
// Waiting for more data
// Got 1KB of data
tw.insert(1000);
// Print average transfer for last 8 seconds
println!("{}", tw.measurement());