## lowhalf-timing.pkg
# Compiled by:
#
src/lib/compiler/back/low/lib/control.libapi Lowhalf_Timing {
time_phase: String -> (X -> Y) -> X -> Y;
};
package low_code_timing: (weak) Lowhalf_Timing { # Lowhalf_Timing is from
src/lib/compiler/back/low/control/lowhalf-timing.pkg fun time_phase name f
=
run
where
timing = lowhalf_control::timing name;
my { gc, usr, sys } = *timing;
fun run x
=
{ timer = cpu_timer::make_cpu_timer();
fun update timer
=
{ t = cpu_timer::get_elapsed_heapcleaner_and_program_usermode_and_kernelmode_cpu_seconds timer;
#
usr' = time::from_float_seconds t.program.usermode_cpu_seconds;
gc' = time::from_float_seconds t.heapcleaner.usermode_cpu_seconds;
sys' = time::from_float_seconds (t.heapcleaner.kernelmode_cpu_seconds + t.program.kernelmode_cpu_seconds);
#
timing := { gc => time::(+) (gc, gc'),
usr => time::(+) (usr, usr'),
sys => time::(+) (sys, sys')
};
};
y = f x
except e
=
{ update timer;
#
raise exception e;
};
update timer; y;
};
end;
};
## COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.