Usage
read t
Signature
read: % MachineInteger
Parameter | Type | Description |
---|---|---|
t | % | The timer to read |
Description
Reads the timer t without stopping it.
Returns
Returns the total accumulated time in milliseconds by all the start/stop cycles since t was created or last reset. This times includes any eventual garbage collection time (see gc to extract this information). If t is running, the time since the last start is added in, and t is not stopped or affected.
Example
The following function takes a positive MachineInteger as input, computes and prints a machine approximation of , and returns the CPU time needed to compute it, but not the time needed to print it.
timeHarmonic(n:MachineInteger):MachineInteger == { import from MachineInteger, SingleFloat, Timer, Character, TextWriter; t := timer(); m:SingleFloat := 1; start! t; for i in 2..n repeat m := m + 1 / (i::SingleFloat); stop! t; stdout << "H" << n << " = " << m << newline; read t; }
See Also
gc, start!, stop!