Struct heatmap::Heatmap
[−]
[src]
pub struct Heatmap { // some fields omitted }
main datastructure of Heatmap
Methods
impl Heatmap
[src]
fn new() -> Heatmap
fn configure() -> Config
configure and build a new Heatmap
Example
let mut heatmap = Heatmap::configure() .precision(4) // set precision to 4 digits .max_value(1_000_000_000) // store values up to 1 Million .slice_duration(1_000_000_000) // 1 second slices .num_slices(300) // 300 slices => 5 minutes of records .build() // create the Heatmap .unwrap();
fn clear(&mut self)
clear the heatmap data
Example
let mut h = Heatmap::new(); h.increment(1, 1); assert_eq!(h.entries(), 1); h.clear(); assert_eq!(h.entries(), 0);
fn increment(&mut self, time: u64, value: u64) -> Result<(), &'static str>
increment the count for a value at a time
Example
extern crate heatmap; extern crate time; let mut h = heatmap::Heatmap::new(); h.increment(time::precise_time_ns(), 1); assert_eq!(h.entries(), 1);
fn increment_by(&mut self, time: u64, value: u64, count: u64) -> Result<(), &'static str>
increment additional counts for value at a time
Example
extern crate heatmap; extern crate time; let mut h = heatmap::Heatmap::new(); h.increment_by(time::precise_time_ns(), 1, 1); assert_eq!(h.entries(), 1); h.increment_by(time::precise_time_ns(), 2, 2); assert_eq!(h.entries(), 3); h.increment_by(time::precise_time_ns(), 10, 10); assert_eq!(h.entries(), 13);
fn get(&mut self, time: u64, value: u64) -> Result<u64, &'static str>
get the count of items at a quantized time-value point
fn entries(&mut self) -> u64
return the number of entries in the Histogram
Example
extern crate heatmap; extern crate time; let mut h = heatmap::Heatmap::new(); assert_eq!(h.entries(), 0); h.increment_by(time::precise_time_ns(), 1, 1); assert_eq!(h.entries(), 1);
fn merge(&mut self, other: &mut Heatmap)
merge one Heatmap into another Heatmap
Example
extern crate heatmap; extern crate time; let mut a = heatmap::Heatmap::configure() .num_slices(60) .slice_duration(1) .build() .unwrap(); let mut b = heatmap::Heatmap::new(); assert_eq!(a.entries(), 0); assert_eq!(b.entries(), 0); let _ = a.increment(0, 1); let _ = b.increment(0, 1); assert_eq!(a.entries(), 1); assert_eq!(b.entries(), 1); a.merge(&mut b); assert_eq!(a.entries(), 2); assert_eq!(a.get(0, 1).unwrap(), 2); assert_eq!(a.get(0, 2).unwrap(), 0); assert_eq!(a.get(1, 1).unwrap(), 0);
fn save(&mut self, file: String)
save the Heatmap
to disk. NOTE: format may change in future
fn load(file: String) -> Heatmap
load the Heatmap
from file. NOTE: format may change in future
fn histogram_buckets(&self) -> u64
returns the number of buckets per Histogram
/ Slice
fn num_slices(&self) -> u64
returns the number of Slice
s within Heatmap
Trait Implementations
impl Clone for Heatmap
[src]
fn clone(&self) -> Heatmap
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> IntoIterator for &'a Heatmap
[src]
type Item = Slice
The type of the elements being iterated over.
type IntoIter = Iter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more