## internal-wallclock-timer.pkg
#
# See also:
#
src/lib/std/src/internal-cpu-timer.pkg#
src/lib/std/src/nj/set-sigalrm-frequency.pkg# Compiled by:
#
src/lib/std/src/standard-core.sublibstipulate
package pb = proto_basis; # proto_basis is from
src/lib/std/src/proto-basis.pkg# package ig = int_guts; # int_guts is from
src/lib/std/src/int-guts.pkg# package i1w = one_word_int_guts; # one_word_int_guts is from
src/lib/std/src/one-word-int-guts.pkg package tim = time_guts; # time_guts is from
src/lib/std/src/time-guts.pkgherein
package internal_wallclock_timer: (weak) api {
include api Wallclock_Timer; # Wallclock_Timer is from
src/lib/std/src/wallclock-timer.api reset_timer: Void -> Void; # Reset global timer to zero elapsed time.
}
{
Time = { usr: pb::Time, # User-mode CPU time consumption for this process.
sys: pb::Time # Kernel-mode CPU time consumption for this process.
};
Wallclock_Timer = WALLCLOCK_TIMER pb::Time;
fun make_wallclock_timer ()
=
WALLCLOCK_TIMER (tim::get_current_time_utc ());
stipulate
init_real_time = REF (make_wallclock_timer ());
herein
fun get_wallclock_timer ()
=
*init_real_time;
# This call is used (only) in
#
src/lib/std/src/nj/runtime-internals.pkg # to clear timers when resuming a heap image
# created by fork_to_disk():
#
fun reset_timer ()
=
init_real_time := make_wallclock_timer ();
end;
fun get_elapsed_wallclock_time (WALLCLOCK_TIMER t)
=
tim::(-) (tim::get_current_time_utc(), t);
};
end;