src/Pure/General/timing.ML
changeset 50777 20126dd9772c
parent 44440 aa2abd81f460
child 50781 a0f22c2d60cc
equal deleted inserted replaced
50776:5a9964f7a691 50777:20126dd9772c
    19   type start
    19   type start
    20   val start: unit -> start
    20   val start: unit -> start
    21   val result: start -> timing
    21   val result: start -> timing
    22   val timing: ('a -> 'b) -> 'a -> timing * 'b
    22   val timing: ('a -> 'b) -> 'a -> timing * 'b
    23   val is_relevant: timing -> bool
    23   val is_relevant: timing -> bool
       
    24   val properties: timing -> Properties.T
    24   val message: timing -> string
    25   val message: timing -> string
    25 end
    26 end
    26 
    27 
    27 structure Timing: TIMING =
    28 structure Timing: TIMING =
    28 struct
    29 struct
    64     val start = start ();
    65     val start = start ();
    65     val y = f x;
    66     val y = f x;
    66   in (result start, y) end;
    67   in (result start, y) end;
    67 
    68 
    68 
    69 
       
    70 (* properties *)
       
    71 
       
    72 fun property name time =
       
    73   [(name, Time.toString time)] handle Time.Time => [];
       
    74 
       
    75 fun properties {elapsed, cpu, gc} =
       
    76   property "time_elapsed" elapsed @
       
    77   property "time_cpu" cpu @
       
    78   property "time_GC" gc;
       
    79 
       
    80 
    69 (* timing messages *)
    81 (* timing messages *)
    70 
    82 
    71 val min_time = Time.fromMilliseconds 1;
    83 val min_time = Time.fromMilliseconds 1;
    72 
    84 
    73 fun is_relevant {elapsed, cpu, gc} =
    85 fun is_relevant {elapsed, cpu, gc} =