Struct heatmap::Heatmap [] [src]

pub struct Heatmap {
    // some fields omitted
}

main datastructure of Heatmap

Methods

impl Heatmap
[src]

create a new Heatmap with defaults

Example

let mut h = Heatmap::new();

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();

clear the heatmap data

Example

extern crate time;
extern crate heatmap;

let mut h = heatmap::Heatmap::new();

h.increment(time::precise_time_ns(), 1);
assert_eq!(h.entries(), 1);
h.clear();
assert_eq!(h.entries(), 0);

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);

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);

get the count of items at a quantized time-value point

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);

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_000_000_000)
    .build()
    .unwrap();

let mut b = heatmap::Heatmap::new();

assert_eq!(a.entries(), 0);
assert_eq!(b.entries(), 0);

let t0 = time::precise_time_ns();
let t1 = t0 + 1_000_000_000;

let _ = a.increment(t0, 1);
let _ = b.increment(t0, 1);

assert_eq!(a.entries(), 1);
assert_eq!(b.entries(), 1);

a.merge(&mut b);

assert_eq!(a.entries(), 2);
assert_eq!(a.get(t0, 1).unwrap(), 2);
assert_eq!(a.get(t0, 2).unwrap(), 0);
assert_eq!(a.get(t1, 1).unwrap(), 0);

save the Heatmap to disk. NOTE: format may change in future

load the Heatmap from file. NOTE: format may change in future

returns the number of buckets per Histogram / Slice

returns the number of Slices within Heatmap

Trait Implementations

impl Clone for Heatmap
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> IntoIterator for &'a Heatmap
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl Default for Heatmap
[src]

Returns the "default value" for a type. Read more