3.20. kink/TICK

Provides funs dealing with ticks, or elapsed machine time.

A tick is represented as the number of seconds. For example, 0.123456789 represents 123456789 nanoseconds.

3.20.1. TICK.sleep(Seconds)

TICK.sleep causes the current thread to sleep for the specified Seconds.

Seconds must be a non-negative num of an arbitrary precision. The maximum precision effective in the result depends on the runtime system. For example, in a Kink runtime system on the JVM, the two invocations of TICK.sleep in the following program are equivalent. Both tries to sleep 1234 milliseconds.

TICK.sleep(1.23456) # tries to sleep 1234 milliseconds
TICK.sleep(1.234)   # tries to sleep 1234 milliseconds

3.20.2. TICK.new_stopwatch

TICK.new_stopwatch makes a stopwatch fun.

The stopwatch fun takes no argument, then returns the elapsed time from the invocation of TICK.new_stopwatch in seconds, with the precision of nanoseconds.

The result of the stopwatch fun is always equal to or greater than zero.

Example (the output varies for each execution):

:elapsed_seconds <- TICK.new_stopwatch
stdout.print_line(elapsed_seconds.repr) # => 1.001089645
stdout.print_line(elapsed_seconds.repr) # => 3.004145317