]> matita.cs.unibo.it Git - helm.git/blob - helm/software/helena/src/lib/time.ml
compile-time feature PROFV to profile validation without sort inclusion
[helm.git] / helm / software / helena / src / lib / time.ml
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic        
3     ||A||  Library of Mathematics, developed at the Computer Science     
4     ||T||  Department, University of Bologna, Italy.                     
5     ||I||                                                                
6     ||T||  HELM is free software; you can redistribute it and/or         
7     ||A||  modify it under the terms of the GNU General Public License   
8     \   /  version 2 or (at your option) any later version.              
9      \ /   This software is distributed as is, NO WARRANTY.              
10       V_______________________________________________________________ *)
11
12 module KP = Printf
13
14 module L = Log
15
16 let level = 1 
17
18 let old = [|0.0; 0.0|]
19
20 let stamp_ix = 0
21
22 let lap_ix = 1
23
24 let gmtime msg =
25    let gmt = Unix.gmtime (Unix.time ()) in
26    let yy = gmt.Unix.tm_year + 1900 in
27    let mm = gmt.Unix.tm_mon + 1 in
28    let dd = gmt.Unix.tm_mday in
29    let h = gmt.Unix.tm_hour in
30    let m = gmt.Unix.tm_min in
31    let s = gmt.Unix.tm_sec in
32    let str = KP.sprintf "UTC TIME STAMP (%s): %u/%u/%u %u:%u:%u" msg yy mm dd h m s in
33    L.warn level str
34
35 let utime_stamp msg = 
36    let times = Unix.times () in
37    let stamp = times.Unix.tms_utime in
38    let lap = stamp -. old.(stamp_ix) in
39    let str = KP.sprintf "USR TIME STAMP (%s): %f (%f)" msg stamp lap in
40    L.warn level str;
41    old.(stamp_ix) <- stamp
42
43 IFDEF PROFV THEN
44
45 let utime_lap msg = 
46    let times = Unix.times () in
47    let stamp = times.Unix.tms_utime in
48    if msg <> "" then begin
49       let lap = stamp -. old.(lap_ix) in
50       let str = KP.sprintf "USR TIME LAP (%s): %f" msg lap in
51       L.warn level str
52    end;
53    old.(lap_ix) <- stamp
54
55 END