## cpu-timer.api
# Compiled by:
#
src/lib/std/src/standard-core.sublib# See also:
#
src/lib/std/src/wallclock-timer.api#
src/lib/std/src/nj/set-sigalrm-frequency.api#
src/lib/compiler/debugging-and-profiling/profiling/profiling-control.api### "All we have to decide
### is what to do with the
### time that is given us."
###
### -- Gandalf
stipulate
package f8b = eight_byte_float_guts; # eight_byte_float_guts is from
src/lib/std/src/eight-byte-float-guts.pkg package i1w = one_word_int_guts; # one_word_int_guts is from
src/lib/std/src/one-word-int-guts.pkg #
Float = f8b::Float;
herein
# This api is implemented in:
#
#
src/lib/std/src/cpu-timer.pkg #
api Cpu_Timer {
#
Cpu_Timer; # Measures CPU time actually used, broken down by user-mode / kernel-mode / garbage-collection.
Cpu_Times
=
{ program: { usermode_cpu_seconds: Float, kernelmode_cpu_seconds: Float }, # CPU time excluding that used by garbage collector.
heapcleaner: { usermode_cpu_seconds: Float, kernelmode_cpu_seconds: Float } # CPU time used by garbage collector.
};
make_cpu_timer: Void -> Cpu_Timer; # Make timer whose time-zero is now.
get_cpu_timer: Void -> Cpu_Timer; # Get timer whose time-zero was set at process start-up.
# The following calls return total CPU
# consumption in this process since
# creation time of the Cpu_Timer.
#
# Thus, successive calls to these functions
# will return monotonically increasing values.
get_elapsed_cpu_seconds
:
Cpu_Timer -> Float; # Sum of times from following call.
get_elapsed_usermode_and_kernelmode_cpu_seconds # CPU time including that used by garbage collector.
:
Cpu_Timer -> { usermode_cpu_seconds: Float, # User-mode CPU time.
kernelmode_cpu_seconds: Float # Kernel-mode CPU time.
};
get_elapsed_heapcleaner_and_program_usermode_and_kernelmode_cpu_seconds # As above, but also broken down by user-code CPU time and garbage-collector CPU time.
:
Cpu_Timer
->
Cpu_Times;
get_elapsed_heapcleaner_cpu_seconds # CPU time used by garbage collector since creation of Cpu_Timer.
:
Cpu_Timer
->
Float;
# The following calls return total CPU
# consumption in this process since
# the previous '*added*' call.
#
# Thus, successive calls to these functions
# will NOT return monotonically increasing values.
get_added_cpu_seconds: Cpu_Timer -> Float; # Sum of times from following call.
get_added_usermode_and_kernelmode_cpu_seconds # CPU seconds including that used by heapcleaner ("garbage collector").
:
Cpu_Timer
->
{ usermode_cpu_seconds: Float, # User-mode CPU seconds.
kernelmode_cpu_seconds: Float # Kernel-mode CPU seconds.
};
get_added_heapcleaner_and_program_usermode_and_kernelmode_cpu_seconds # As above, but also broken down by user-code CPU time and garbage-collector CPU time.
:
Cpu_Timer
->
{ program: { usermode_cpu_seconds: Float, kernelmode_cpu_seconds: Float }, # CPU time excluding that used by garbage collector.
heapcleaner: { usermode_cpu_seconds: Float, kernelmode_cpu_seconds: Float } # CPU time used by garbage collector.
};
#######################################################################
# Below stuff is intended only for one-time use during
# booting, to switch from direct to indirect syscalls: # For background see Note[1] in
src/lib/std/src/unsafe/mythryl-callable-c-library-interface.pkg gettime__syscall: Void -> (i1w::Int,Int, i1w::Int,Int, i1w::Int,Int);
set__gettime__ref: ({ lib_name: String, fun_name: String, io_call: (Void -> (i1w::Int,Int, i1w::Int,Int, i1w::Int,Int)) } -> (Void -> (i1w::Int,Int, i1w::Int,Int, i1w::Int,Int))) -> Void;
};
end;
## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.