OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
Timer.h
1// =====================================================================================================================
2// OpenShaderDesigner, an open source software utility to create materials and shaders.
3// Copyright (C) 2024 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
19#ifndef TIMER_H
20#define TIMER_H
21
22#include <chrono>
23
24namespace OpenShaderDesigner
25{
26
27class Timer
28{
29public:
30 Timer() : Start(std::chrono::high_resolution_clock::now()) { }
31
32 void Reset() { Start = std::chrono::high_resolution_clock::now(); }
33
34 [[nodiscard]] double Poll() const
35 { return std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - Start).count(); }
36private:
37 std::chrono::high_resolution_clock::time_point Start;
38};
39
40}
41
42#endif //TIMER_H
Definition Timer.h:28