Struct histogram::Histogram [] [src]

pub struct Histogram { /* fields omitted */ }

the main datastructure

Methods

impl Histogram
[src]

[src]

create a new Histogram

Example

let mut h = Histogram::new();

[src]

configure a Histogram

Example

let mut h = Histogram::configure()
    .max_value(10_000)
    .build()
    .unwrap();

[src]

clear the histogram data

Example

let mut h = Histogram::new();

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

[src]

increment the count for a value

Example

use histogram::Histogram;

let mut h = Histogram::new();

h.increment(1);
assert_eq!(h.get(1).unwrap(), 1);

[src]

record additional counts for value

Example

let mut h = Histogram::new();

h.increment_by(1, 1);
assert_eq!(h.get(1).unwrap(), 1);

h.increment_by(2, 2);
assert_eq!(h.get(2).unwrap(), 2);

h.increment_by(10, 10);
assert_eq!(h.get(10).unwrap(), 10);

[src]

decrement the count for a value. This functionality is best used to remove previously inserted from the histogram.

Example

let mut h = Histogram::new();

h.increment(1).unwrap();
assert_eq!(h.get(1).unwrap(), 1);
h.decrement(1).unwrap();
assert_eq!(h.get(1).unwrap(), 0);

[src]

remove count for value from histogram. This functionality is best used to remove previously inserted from the histogram.

Example

let mut h = Histogram::new();

h.increment_by(1, 1).unwrap();
h.increment_by(2, 2).unwrap();
h.decrement_by(1, 1).unwrap();

assert_eq!(h.get(2).unwrap(), 2);
assert_eq!(h.get(1).unwrap(), 0);

[src]

get the count for a value

Example

let mut h = Histogram::new();
assert_eq!(h.get(1).unwrap(), 0);

[src]

return the value for the given percentile

Example

let mut h = Histogram::new();
for value in 1..1000 {
    h.increment(value).unwrap();
}

assert_eq!(h.percentile(50.0).unwrap(), 501);
assert_eq!(h.percentile(90.0).unwrap(), 901);
assert_eq!(h.percentile(99.0).unwrap(), 991);
assert_eq!(h.percentile(99.9).unwrap(), 999);

[src]

convenience function for min

Example

let mut h = Histogram::new();
for value in 1..1000 {
    h.increment(value);
}
assert_eq!(h.minimum().unwrap(), 1);

[src]

convenience function for max

Example

let mut h = Histogram::new();
for value in 1..1000 {
    h.increment(value);
}
assert_eq!(h.maximum().unwrap(), 999);

[src]

arithmetic mean approximation across the histogram

Example

let mut h = Histogram::new();
for value in 1..1000 {
    h.increment(value);
}
assert_eq!(h.mean().unwrap(), 500);

[src]

standard variance approximation across the histogram

Example

let mut h = Histogram::new();
for value in 1..11 {
    h.increment(value);
}
assert_eq!(h.stdvar().unwrap(), 9);

[src]

standard deviation approximation across the histogram

Example

let mut h = Histogram::new();

for value in 1..11 {
    h.increment(value);
}

assert_eq!(h.stddev().unwrap(), 3);

h.clear();

for value in 1..4 {
    h.increment(value);
}
for _ in 0..26 {
    h.increment(1);
}

assert_eq!(h.stddev().unwrap(), 1);

[src]

merge one Histogram into another Histogram

Example

let mut a = Histogram::new();
let mut b = Histogram::new();

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

a.increment(1);
b.increment(2);

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

a.merge(&mut b);

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

[src]

return the number of entries in the Histogram

Example

let mut h = Histogram::new();

assert_eq!(h.entries(), 0);
h.increment(1);
assert_eq!(h.entries(), 1);

[src]

return the number of buckets in the Histogram

Example

let mut h = Histogram::new();

assert!(h.buckets_total() > 1);

Trait Implementations

impl Clone for Histogram
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

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

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl Debug for Histogram
[src]

[src]

Formats the value using the given formatter. Read more

impl Default for Histogram
[src]

[src]

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

Auto Trait Implementations

impl Send for Histogram

impl Sync for Histogram