Browse thread
Unix module troubles & Time functions
-
Julien Michel
- Jean-Christophe Filliatre
- William D. Neumann
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jean-Christophe Filliatre <filliatr@l...> |
| Subject: | Re: [Caml-list] Unix module troubles & Time functions |
Julien Michel writes: > I would like to measure the time a function spends inside a Caml > program, for performance purpose. > I need a function with an accuracy of at least 1us. > [...] > Or generally speaking, does any other function exists to achieve such a > measurement (accuracy about 1 us) ? To do such a measurement, I'm using the Unix.times function, as follows: ====================================================================== open Unix let utime f x = let u = (times()).tms_utime in let y = f x in let ut = (times()).tms_utime -. u in (y,ut) let print_utime f x = let (y,ut) = utime f x in Printf.printf "user time: %2.2f\n" ut; y ====================================================================== Hope this helps, -- Jean-Christophe Filliātre (http://www.lri.fr/~filliatr)