src/HOL/Matrix_LP/Compute_Oracle/report.ML
author wenzelm
Sun, 20 May 2012 11:34:33 +0200
changeset 47884 21c42b095c84
parent 46988 9f492f5b0cec
child 62391 1658fc9b2618
permissions -rw-r--r--
try to avoid races again (cf. 8c37cb84065f and fd3a36e48b09);

structure Report =
struct

local

    val report_depth = Unsynchronized.ref 0
    fun space n = if n <= 0 then "" else (space (n-1))^" "
    fun report_space () = space (!report_depth)

in

fun timeit f =
    let
        val t1 = Timing.start ()
        val x = f ()
        val t2 = Timing.message (Timing.result t1)
        val _ = writeln ((report_space ()) ^ "--> "^t2)
    in
        x       
    end

fun report s f = 
let
    val _ = writeln ((report_space ())^s)
    val _ = report_depth := !report_depth + 1
    val x = timeit f
    val _ = report_depth := !report_depth - 1
in
    x
end

end
end