src/Pure/RAW/ml_profiling_polyml.ML
author Manuel Eberl <eberlm@in.tum.de>
Tue, 19 Jan 2016 11:19:25 +0100
changeset 62201 eca7b38c8ee5
parent 61925 ab52f183f020
permissions -rw-r--r--
Added approximation of powr to NEWS/CONTRIBUTORS

(*  Title:      Pure/RAW/ml_profiling_polyml.ML
    Author:     Makarius

Profiling for Poly/ML.
*)

structure ML_Profiling =
struct

local

fun profile n f x =
  let
    val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler n;
    val res = Exn.capture f x;
    val _ = RunCall.run_call1 RuntimeCalls.POLY_SYS_profiler 0;
  in Exn.release res end;

in

fun profile_time (_: (int * string) list -> unit) f x = profile 1 f x;
fun profile_time_thread (_: (int * string) list -> unit) f x = profile 6 f x;
fun profile_allocations (_: (int * string) list -> unit) f x = profile 2 f x;

end;

end;