HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Stopwatch.h
Go to the documentation of this file.
1#pragma once
2#include "HephShared.h"
3#include <chrono>
4
7#define HEPH_SW_NANO (1e-9)
8#define HEPH_SW_MICRO (1e-6)
9#define HEPH_SW_MILLI (1e-3)
10
15#define HEPH_SW_RESET Heph::Stopwatch::GetInstance().Reset()
16
22#define HEPH_SW_DT Heph::Stopwatch::GetInstance().DeltaTime()
23
28#define HEPH_SW_DT_S Heph::Stopwatch::GetInstance().DeltaTime()
29
34#define HEPH_SW_DT_MS Heph::Stopwatch::GetInstance().DeltaTime(HEPH_SW_MILLI)
35
40#define HEPH_SW_DT_US Heph::Stopwatch::GetInstance().DeltaTime(HEPH_SW_MICRO)
41
46#define HEPH_SW_DT_NS Heph::Stopwatch::GetInstance().DeltaTime(HEPH_SW_NANO)
47
48namespace Heph
49{
54 class HEPH_API Stopwatch final
55 {
56 private:
57 std::chrono::steady_clock::time_point tp;
58
59 public:
62
67 void Reset();
68
73 double DeltaTime() const;
74
80 double DeltaTime(double prefix) const;
81
86 static Stopwatch& GetInstance() noexcept;
87 };
88}
#define HEPH_API
Definition HephShared.h:132
class for measuring time.
Definition Stopwatch.h:55
double DeltaTime(double prefix) const
static Stopwatch & GetInstance() noexcept
gets the instance that's local to the current thread.
double DeltaTime() const