Crates.io | downsample |
lib.rs | downsample |
version | 0.0.3 |
source | src |
created_at | 2023-01-06 11:27:33.728918 |
updated_at | 2023-10-22 13:10:39.160294 |
description | keep downsampled history of data over long period of time |
homepage | https://gitlab.com/xMAC94x/downsample |
repository | https://gitlab.com/xMAC94x/downsample |
max_upload_size | |
id | 752249 |
size | 42,905 |
no-std library to downsample fixed-frequency or time-based metrics for long history storage.
Let's assume you have a temperature sensor that can do 100 measurements per second and stores the data in a f32
.
You want to keep track of some historic samples, like from last year, but you don't need them at the same 100Hz as your raw data as 365 * 24 * 60 * 60 * 100 * 4byte = 12GB
is just to much data.
Alternativly it will provide a time-based downsampler where you can store data in levels with no fixed size but a fixed interval. time-based downsampling is not yet implemented.
use downsample::FixedFrequencyBuilder;
use rand::Rng;
fn main() {
// 0s - 1s : 100Hz
// 1s - 1m : 1Hz
// 1m - 1h : 1/60 Hz
// 1h - 1d : 1/3600 Hz
let mut temperature_measurements = FixedFrequencyBuilder::new(100, 100)
.level(59, 100)
.level(59, 60)
.level(23, 60)
.build();
for _ in 0..1000 {
temperature_measurements.push(rng.gen::<f32>());
}
}
This crate is in version 0.0.x
that means the api will change rapidly, traits will change nothing is even nearly stable yet