Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Timer.hpp
1// Copyright 2022 ShenMian
2// License(Apache-2.0)
3
4#pragma once
5
6#include <chrono>
7
15class Timer
16{
17public:
18 using clock = std::chrono::high_resolution_clock;
19
20 Timer() { restart(); }
21
22 void restart() noexcept { start_ = clock::now(); }
23
24 auto get_milliseconds() const noexcept
25 {
26 return std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start_).count();
27 }
28
29 auto get_seconds() const noexcept { return static_cast<double>(get_milliseconds()) / 1000.0; }
30
31private:
32 std::chrono::time_point<clock> start_;
33};
34
计时器.
Definition: Timer.hpp:16