class SF::Clock
- SF::Clock
- Reference
- Object
Overview
Utility class that measures the elapsed time
SF::Clock
is a lightweight class for measuring time.
Its provides the most precise time that the underlying OS can achieve (generally microseconds or nanoseconds). It also ensures monotonicity, which means that the returned time can never go backward, even if the system time is changed.
Usage example:
clock = SF::Clock.new
# [...]
time1 = clock.elapsed_time
# [...]
time2 = clock.restart
The SF::Time
value returned by the clock can then be
converted to a number of seconds, milliseconds or even
microseconds.
See also: SF::Time
Defined in:
system/obj.crConstructors
-
.new
Default constructor
Instance Method Summary
-
#dup : Clock
Returns a shallow copy of this object.
-
#elapsed_time : Time
Get the elapsed time
- #finalize
-
#restart : Time
Restart the clock
Constructor Detail
Instance Method Detail
Returns a shallow copy of this object.
This allocates a new object and copies the contents of
self
into it.
Get the elapsed time
This function returns the time elapsed since the last call
to #restart()
(or the construction of the instance if #restart()
has not been called).
Returns: Time elapsed
Restart the clock
This function puts the time counter back to zero. It also returns the time elapsed since the clock was started.
Returns: Time elapsed