Skip to main content

Stopwatch Class

A high-resolution timer based on std::chrono::steady_clock. More...

Declaration

class helios::engine::util::time::Stopwatch { ... }

Public Constructors Index

Stopwatch () noexcept=default

Constructs and starts the stopwatch. More...

Public Member Functions Index

voidstart () noexcept

Starts (or restarts) the timer. Captures the current timestamp. More...

floatelapsedMs () const noexcept

Returns the time elapsed since start() was called. More...

floatelapsedSeconds () const noexcept

Returns the time elapsed in seconds. More...

Private Member Attributes Index

std::chrono::time_point< std::chrono::steady_clock >start_ {std::chrono::steady_clock::now()}

Description

A high-resolution timer based on std::chrono::steady_clock.

Used to measure elapsed time intervals with the highest precision provided by the OS (suitable for frame time measurements and profiling).

Definition at line 20 of file Stopwatch.ixx.

Public Constructors

Stopwatch()

helios::engine::util::time::Stopwatch::Stopwatch ()
noexcept default

Constructs and starts the stopwatch.

The stopwatch is initialized to the current time so queries are well-defined immediately after construction.

Definition at line 33 of file Stopwatch.ixx.

Public Member Functions

elapsedMs()

float helios::engine::util::time::Stopwatch::elapsedMs ()
inline noexcept

Returns the time elapsed since start() was called.

Returns

The elapsed time in milliseconds as a floating point value.

Definition at line 48 of file Stopwatch.ixx.

49 auto end = std::chrono::steady_clock::now();
50 // Wichtig: Expliziter Cast zu float Millisekunden
51 std::chrono::duration<float, std::milli> duration = end - start_;
52 return duration.count();
53 }

elapsedSeconds()

float helios::engine::util::time::Stopwatch::elapsedSeconds ()
inline noexcept

Returns the time elapsed in seconds.

Returns

The elapsed time in seconds as a floating point value.

Definition at line 60 of file Stopwatch.ixx.

61 auto end = std::chrono::steady_clock::now();
62 std::chrono::duration<float> duration = end - start_;
63 return duration.count();
64 }

Referenced by helios::engine::tooling::FramePacer::sync.

start()

void helios::engine::util::time::Stopwatch::start ()
inline noexcept

Starts (or restarts) the timer. Captures the current timestamp.

Definition at line 39 of file Stopwatch.ixx.

39 void start() noexcept {
40 start_ = std::chrono::steady_clock::now();
41 }

Referenced by helios::engine::tooling::FramePacer::beginFrame.

Private Member Attributes

start_

std::chrono::time_point<std::chrono::steady_clock> helios::engine::util::time::Stopwatch::start_ {std::chrono::steady_clock::now()}

Definition at line 24 of file Stopwatch.ixx.

24 std::chrono::time_point<std::chrono::steady_clock> start_{std::chrono::steady_clock::now()};

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.