
3 The MLWorks Pervasive Library
Time structure is deprecated because it has been superseded by the Standard ML Basis library structures Time and Timer. The Basis structure Time corresponds to MLWorks.Time.Interval, and the Basis structure Timer to MLWorks.Time.Elapsed. Because Time is used by the MLWorks profiler, we have documented it minimally here. However, the profiler will use Basis time facilities in a future release.
The Time.Elapsed structure is for representing elapsed times.
The datatype T, values of which admit equality, is for representing elapsed times:
datatype T = ELAPSED of {real: Interval.T,
user: Interval.T,
system: Interval.T,
gc: Interval.T}
Arithmetic operations are defined for use on elapsed times:
val * : T * real -> T val + : T * T -> T val - : T * T -> T val / : T * real -> TThe function
elapsed returns the time elapsed since (the current) MLWorks started:
val elapsed : unit -> TThe function
elapsed_since is provided for efficiency.
val elapsed_since : T -> TThe
format function formats an elapsed time into a string.
val format: T -> stringA typical output might be
"1.23 (user: 1.07, system: 0.06, gc: 0.03)"The
Time.Interval structure is for expressing the difference between two clock times.
The datatype T is the same as that for Elapsed.
eqtype TThe functions
from_real and to_real convert to and from floating-point representations of seconds:
val from_real : real -> T
val to_real : T -> real
Arithmetic operations are defined for use on intervals, too:
val * : T * real -> T
val + : T * T -> T
val - : T * T -> T
val / : T * real -> T
val < : T * T -> bool
The following items format intervals:
val decimal_places : int ref val format : T -> stringAt the top level of the
Time structure, there are items for expressing clock times.The type of clock times:
eqtype timeTime zones:
datatype zone = GREENWICH | LOCALArithmetic operations on clock times:
val + : time * Interval.T -> time val - : time * Interval.T -> time val < : time * time -> boolThe
decode function converts a clock time to a string, and encode converts a string to a clock time:
val decode : string -> time val encode : time -> stringClock time formatting (ANSI C's
strftime):
val format : string * zone * time -> stringThe interval function returns the interval between two clock times:
val interval: time * time -> Interval.TThe current clock time can be found with the function
now, which reads the clock:
val now : unit -> timeThe constant for time "zero":
val zero : time

Generated with Harlequin WebMaker