Import Upstream version 20180207
[hcoop/debian/mlton.git] / doc / guide / src / MLtonRusage.adoc
CommitLineData
7f918cf1
CE
1MLtonRusage
2===========
3
4[source,sml]
5----
6signature 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+
18corresponds to a subset of the C `struct rusage`.
19
20* `measureGC b`
21+
22controls whether garbage collection time is separately measured during
23program 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
26either `gc-messages` or `gc-summary` is given as a
27<:RunTimeOptions:runtime system option>.
28
29* `rusage ()`
30+
31corresponds to the C `getrusage` function. It returns the resource
32usage of the exited children, the garbage collector, and the process
33itself. The `self` component includes the usage of the `gc`
34component, 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
37the start of the program (it can still be disable by user code later).