# Module Stats

    module Stats: sig .. end

Utilities for maintaining timing statistics

`type ``timerModeEnum =`

`|` | `Disabled` | `(*` | Do not collect timing information | `*)`
`|` | `SoftwareTimer` | `(*` | Use OCaml's `Unix.time` for timing information | `*)`
`|` | `HardwareTimer` | `(*` | Use the Pentium's cycle counter to time code | `*)`
`|` | `HardwareIfAvail` | `(*` | Use the hardware cycle counter if availible; otherwise use SoftwareTimer | `*)`

Whether to use the performance counters (on Pentium only)

    val reset : timerModeEnum -> unit

Resets all the timings and specifies the method to use for future timings. Call this before doing any timing. You will get an exception if you pass HardwareTimer to reset and the hardware counters are not available

    exception NoPerfCount

    val has_performance_counters : unit -> bool

Check if we have performance counters

    val sample_pentium_perfcount_20 : unit -> int

Sample the current cycle count, in megacycles.

    val sample_pentium_perfcount_10 : unit -> int

Sample the current cycle count, in kilocycles.

    val time : string -> ('a -> 'b) -> 'a -> 'b

Time a function and associate the time with the given string. If some timing information is already associated with that string, then accumulate the times. If this function is invoked within another timed function then you can have a hierarchy of timings

    val repeattime : float -> string -> ('a -> 'b) -> 'a -> 'b

repeattime is like time but runs the function several times until the total running time is greater or equal to the first argument. The total time is then divided by the number of times the function was run.

    val print : out_channel -> string -> unit

Print the current stats preceeded by a message

    val lookupTime : string -> float

Return the cumulative time of all calls to `Stats.time` and `Stats.repeattime` with the given label.

    val lastTime : float ref

Time a function and set lastTime to the time it took

    val timethis : ('a -> 'b) -> 'a -> 'b