16.2 Measuring Time and Space
import: rhombus/measure | package: rhombus-lib |
If the ~gc option is specified, then memory.gc is called before the body sequence, and time required for the garbage collection is not counted as part of the reported time.
> measure.time:
"useless"
cpu time: 25 real time: 25 gc time: 0
"useless"
> measure.memory:
[1, 2]
allocated: 800
[1, 2]
expression | ||||
|
function | |
| |
| |
function | |
| |
| |
function | |
|
The measure.real_milliseconds function returns the number of milliseconds elapsed in real time since an unspecified starting time. Unlike system.milliseconds, which is sensitive to the system clock and may therefore retreat or advance more quickly than real time if the system clock is adjusted, results from measure.real_milliseconds will always advance with real time within a process, but results across processes are not comparable.
The measure.gc_milliseconds function returns the amount of processor time in fixnum milliseconds that has been consumed by garbage collection so far. This time is a portion of the time reported by measure.cpu_milliseconds, and is similarly limited.