On this page:
time
memory
time_  and_  memory
8.12

9.2 Measure🔗ℹ

 import: rhombus/measure package: rhombus-prototype

expression

time:

  option; ...

  body

  ...

 

option

 = 

~gc

Returns the same value(s) as the body sequence, but first prints to the current output port the amount of time elapsed during the evaluation of body sequence.

If the ~gc option is specified, then runtime.gc is called before the body sequence, and time required for the garbage collection is not counted as part of the reported time.

> import rhombus/measure

> measure.time:

    for all:

      each i: 0..10000000

      "useless"

cpu time: 22 real time: 22 gc time: 0

"useless"

expression

memory:

  body

  ...

Returns the same value(s) as the body sequence, but first prints to the current output port information about allocation during the evaluation of body sequence.

> import rhombus/measure

> measure.memory:

    for all:

      each i: 0..10

      [1, 2]

allocated: 1056

[1, 2]

expression

time_and_memory:

  option; ...

  body

  ...

Combines measure.time and measure.memory.