equal
deleted
inserted
replaced
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_time: Time.time -> bool |
23 val is_relevant_time: Time.time -> bool |
24 val is_relevant: timing -> bool |
24 val is_relevant: timing -> bool |
25 val message: timing -> string |
25 val message: timing -> string |
26 val protocol_message: Properties.T -> timing -> unit |
26 val protocol_message: string -> Position.T -> timing -> unit |
27 val protocol: Properties.T -> ('a -> 'b) -> 'a -> 'b |
27 val protocol: string -> Position.T -> ('a -> 'b) -> 'a -> 'b |
28 end |
28 end |
29 |
29 |
30 structure Timing: TIMING = |
30 structure Timing: TIMING = |
31 struct |
31 struct |
32 |
32 |
101 |
101 |
102 fun timeit e = cond_timeit true "" e; |
102 fun timeit e = cond_timeit true "" e; |
103 fun timeap f x = timeit (fn () => f x); |
103 fun timeap f x = timeit (fn () => f x); |
104 fun timeap_msg msg f x = cond_timeit true msg (fn () => f x); |
104 fun timeap_msg msg f x = cond_timeit true msg (fn () => f x); |
105 |
105 |
106 fun protocol_message props t = |
106 fun protocol_message name pos t = |
107 if is_relevant t then |
107 if is_relevant t then |
108 Output.try_protocol_message (props @ Markup.timing_properties t) [] |
108 let val props = Markup.command_timing :: (Markup.nameN, name) :: Position.properties_of pos |
|
109 in Output.try_protocol_message (props @ Markup.timing_properties t) [] end |
109 else (); |
110 else (); |
110 |
111 |
111 fun protocol props f x = |
112 fun protocol name pos f x = |
112 let |
113 let |
113 val (t, result) = timing (Exn.interruptible_capture f) x; |
114 val (t, result) = timing (Exn.interruptible_capture f) x; |
114 val _ = protocol_message props t; |
115 val _ = protocol_message name pos t; |
115 in Exn.release result end; |
116 in Exn.release result end; |
116 |
117 |
117 end; |
118 end; |
118 |
119 |
119 structure Basic_Timing: BASIC_TIMING = Timing; |
120 structure Basic_Timing: BASIC_TIMING = Timing; |