1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! Timekeeper is a simple library to track the amount of time used by different
//! parts of a program.

extern crate libc;

mod simpletracker;
mod source;

pub use crate::simpletracker::SimpleTracker;
pub use crate::source::*;

#[cfg(feature = "enable_timekeeper")] mod timer;
#[cfg(feature = "enable_timekeeper")] mod timerset;
#[cfg(feature = "enable_timekeeper")] pub use crate::timer::*;
#[cfg(feature = "enable_timekeeper")] pub use crate::timerset::*;

#[cfg(not(feature = "enable_timekeeper"))] mod nop_timer;
#[cfg(not(feature = "enable_timekeeper"))] mod nop_timerset;
#[cfg(not(feature = "enable_timekeeper"))] pub use nop_timer::*;
#[cfg(not(feature = "enable_timekeeper"))] pub use nop_timerset::*;

pub trait Tracker: Default {
    type Statistics: Default;

    fn record(&mut self, time: u64);
    fn get_stats(&self, partial_time: Option<u64>) -> Self::Statistics;
    fn get(&self, partial_time: Option<u64>) -> u64;
}

pub trait Source: Default {
    fn get_time(&self) -> u64;
}