src/Tools/Compute_Oracle/report.ML
author boehmes
Wed, 07 Apr 2010 20:38:11 +0200
changeset 36082 8f10b0e77d94
parent 32960 69916a850301
permissions -rw-r--r--
fail for problems containg the universal sort (as those problems cannot be atomized)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25218
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     1
structure Report =
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     2
struct
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     3
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     4
local
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     5
32740
9dd0a2f83429 explicit indication of Unsynchronized.ref;
wenzelm
parents: 30187
diff changeset
     6
    val report_depth = Unsynchronized.ref 0
25218
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     7
    fun space n = if n <= 0 then "" else (space (n-1))^" "
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     8
    fun report_space () = space (!report_depth)
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
     9
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    10
in
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    11
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    12
fun timeit f =
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    13
    let
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32740
diff changeset
    14
        val t1 = start_timing ()
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32740
diff changeset
    15
        val x = f ()
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32740
diff changeset
    16
        val t2 = #message (end_timing t1)
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32740
diff changeset
    17
        val _ = writeln ((report_space ()) ^ "--> "^t2)
25218
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    18
    in
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32740
diff changeset
    19
        x       
25218
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    20
    end
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    21
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    22
fun report s f = 
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    23
let
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    24
    val _ = writeln ((report_space ())^s)
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    25
    val _ = report_depth := !report_depth + 1
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    26
    val x = timeit f
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    27
    val _ = report_depth := !report_depth - 1
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    28
in
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    29
    x
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    30
end
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    31
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    32
end
fcf0f50e478c better compute oracle
obua
parents:
diff changeset
    33
end