| author | wenzelm | 
| Wed, 22 Aug 2012 22:55:41 +0200 | |
| changeset 48891 | c0eafbd55de3 | 
| parent 46988 | 9f492f5b0cec | 
| child 62391 | 1658fc9b2618 | 
| permissions | -rw-r--r-- | 
| 25218 | 1 | structure Report = | 
| 2 | struct | |
| 3 | ||
| 4 | local | |
| 5 | ||
| 32740 | 6 | val report_depth = Unsynchronized.ref 0 | 
| 25218 | 7 | fun space n = if n <= 0 then "" else (space (n-1))^" " | 
| 8 | fun report_space () = space (!report_depth) | |
| 9 | ||
| 10 | in | |
| 11 | ||
| 12 | fun timeit f = | |
| 13 | let | |
| 42012 
2c3fe3cbebae
structure Timing: covers former start_timing/end_timing and Output.timeit etc;
 wenzelm parents: 
37872diff
changeset | 14 | val t1 = Timing.start () | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32740diff
changeset | 15 | val x = f () | 
| 42012 
2c3fe3cbebae
structure Timing: covers former start_timing/end_timing and Output.timeit etc;
 wenzelm parents: 
37872diff
changeset | 16 | val t2 = Timing.message (Timing.result t1) | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32740diff
changeset | 17 | val _ = writeln ((report_space ()) ^ "--> "^t2) | 
| 25218 | 18 | in | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
32740diff
changeset | 19 | x | 
| 25218 | 20 | end | 
| 21 | ||
| 22 | fun report s f = | |
| 23 | let | |
| 24 | val _ = writeln ((report_space ())^s) | |
| 25 | val _ = report_depth := !report_depth + 1 | |
| 26 | val x = timeit f | |
| 27 | val _ = report_depth := !report_depth - 1 | |
| 28 | in | |
| 29 | x | |
| 30 | end | |
| 31 | ||
| 32 | end | |
| 33 | end |