Skip to main content

Stopwatch.ixx File

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

Included Headers

#include <chrono>

Namespaces Index

namespacehelios
namespaceengine
namespaceutil
namespacetime

Classes Index

classStopwatch

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

Description

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

File Listing

The file content with the documentation metadata removed is:

1
6module;
7
8#include <chrono>
9
10export module helios.engine.util.time.Stopwatch;
11
12export namespace helios::engine::util::time {
13
20 class Stopwatch {
21
22 private:
23 // Initialize to now so elapsed() is well-defined even if start() wasn't called explicitly.
24 std::chrono::time_point<std::chrono::steady_clock> start_{std::chrono::steady_clock::now()};
25
26 public:
34
39 void start() noexcept {
40 start_ = std::chrono::steady_clock::now();
41 }
42
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 }
54
61 auto end = std::chrono::steady_clock::now();
62 std::chrono::duration<float> duration = end - start_;
63 return duration.count();
64 }
65
66 };
67}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.