Class TimerObj#

Inheritance Relationships#

Base Type#

  • public ffi::Object

Class Documentation#

class TimerObj : public ffi::Object#

Base class for all timer implementations.

New implementations of this interface should make sure that Start and Stop are as lightweight as possible. Expensive state synchronization should be done in SyncAndGetElapsedNanos.

Public Functions

virtual void Start() = 0#

Start the timer.

Note: this function should only be called once per object.

virtual void Stop() = 0#

Stop the timer.

Note: this function should only be called once per object.

virtual int64_t SyncAndGetElapsedNanos() = 0#

Synchronize timer state and return elapsed time between Start and Stop.

This function is necessary because we want to avoid timing the overhead of doing timing. When using multiple timers, it is recommended to stop all of them before calling SyncAndGetElapsedNanos on any of them.

Note: this function should be only called once per object. It may incur a large synchronization overhead (for example, with GPUs).

Returns:

The time in nanoseconds between Start and Stop.

inline virtual ~TimerObj()#

Public Static Functions

static inline int32_t _GetOrAllocRuntimeTypeIndex()#
static inline int32_t RuntimeTypeIndex() noexcept#