Import std.time.clock
std.time.clock
The monotonic clock, which never goes back or jumps as the OS's clock can, for how long things take: Instant, a reading of it; Stopwatch and Measure over it; and Sleep. The real clock's time is Timestamp's (in timestamp.fb). What reads the clock here, and in timers.fb, also takes an Instant, so code, and its tests, can give the time as a value.
std/time/clock.fb
Types
Instant
struct
Public Struct Instant Implements Comparable, Hashable, Printable, Defaultable
A reading of the monotonic clock: nanoseconds since a moment of its own, which only means something beside the program's other Instants.
-
Now, as the clock counts it.
-
The Instant that many nanoseconds after the clock's start, for code that gives the time.
-
The value to start from, like 0 for a number, "" for a String, or an empty collection.
-
How many nanoseconds after the clock's start it is.
-
How long it's been since it, now.
-
baftera. Past what an Int64 of nanoseconds holds, about 292 years, it overflows as an Int64 does. -
bbeforea. Past what an Int64 of nanoseconds holds, about 292 years, it overflows as an Int64 does. -
How long it is from
btoa. Past what an Int64 of nanoseconds holds, about 292 years, it overflows as an Int64 does. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
How long after the clock's start it is, like "1h2m3.5s".
Stopwatch
class
Public Class Stopwatch
Measures how long goes by while it runs, over as many starts and stops as it has.
-
A Stopwatch at 0 that isn't running.
-
A Stopwatch running from now, or from the Instant.
-
A Stopwatch running from
now. -
Whether it's running.
-
What it's measured, now or at the Instant.
-
What it's measured at
now. -
Starts it, now or at the Instant, unless it's running.
-
Starts it at
now, unless it's running. -
Stops it, now or at the Instant, keeping what it measured, unless it's stopped.
-
Stops it at
now, keeping what it measured, unless it's stopped. -
Stops it at 0.
-
Starts it again from 0, now or at the Instant.
-
Starts it again from 0, at
now.
Functions
Measure
function
Public Function Measure(work: Func()): Duration
How long the work takes, on the monotonic clock.
Sleep
function
Public Function Sleep(time: Duration)
Blocks the thread for that long, and returns at once for a Duration that isn't above 0. In Async code, Await Wait or Timer.After waits without blocking.
Report an issue with this page or with FutureBlitz on GitHub.