Backport from sid to buster
[hcoop/debian/mlton.git] / doc / guide / src / MLtonRusage.adoc
1 MLtonRusage
2 ===========
3
4 [source,sml]
5 ----
6 signature MLTON_RUSAGE =
7 sig
8 type t = {utime: Time.time, (* user time *)
9 stime: Time.time} (* system time *)
10
11 val measureGC: bool -> unit
12 val rusage: unit -> {children: t, gc: t, self: t}
13 end
14 ----
15
16 * `type t`
17 +
18 corresponds to a subset of the C `struct rusage`.
19
20 * `measureGC b`
21 +
22 controls whether garbage collection time is separately measured during
23 program execution. This affects the behavior of both `rusage` and
24 `Timer.checkCPUTimes`, both of which will return gc times of zero with
25 `measureGC false`. Garbage collection time is always measured when
26 either `gc-messages` or `gc-summary` is given as a
27 <:RunTimeOptions:runtime system option>.
28
29 * `rusage ()`
30 +
31 corresponds to the C `getrusage` function. It returns the resource
32 usage of the exited children, the garbage collector, and the process
33 itself. The `self` component includes the usage of the `gc`
34 component, regardless of whether `measureGC` is `true` or `false`. If
35 `rusage` is used in a program, either directly, or indirectly via the
36 `Timer` structure, then `measureGC true` is automatically called at
37 the start of the program (it can still be disable by user code later).