For a tutorial on using Core_profiler
please look at:
http://docs/programming/performance/core_profiler.html
This interface file defines the Profiler_intf
interface, which has three
implementations:
(1) By opening Core_profiler_disabled.Std
you get an implementation of the interface
where the profiling functions are no-ops.
(2) By opening Core_profiler.Std_online
you get an implementation where the
profiling stats like mean, stddev etc are maintained online, i.e. in-process with the
process that is being profiled. Running the online profiler causes the program to
print a table of stats periodically to stdout as your program runs.
(3) By opening Core_profiler.Std_offline
you get the implementation where the
profiling data is held in-memory in a buffer and is written out to a file at process
exit and the stats can be analyzed offline. For most programs this is the preferred
approach to profiling.
Broadly, there are two ways to collect metrics using Core_profiler
:
(1) One can collect time-stamped metrics at various points in your programs using
Probe
s. The metrics are integers that represent some application specific quantity,
for example the length of some list, the number of allocated words on the heap etc.
(2) Alternately, one can use Timer
s to collect time stamps without recording any
associated metric. Timer
s are a special kind of Probe
that are useful when one
only wants to measure *when something happened* and there is no associated quantity to
measure. Timer
s are strictly less general than Probe
s, but are slightly more
efficient.
module type Probe : sig ... end
module type Profiler_intf : sig ... end
All three profilers -- the disabled one, the online one and the offline one --
implement Profiler_intf
.