yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
754 B27 linesraw
1#ifndef PLATFORM_PERFORMANCE_COUNTER_H
2#define PLATFORM_PERFORMANCE_COUNTER_H
3
4#include <chrono>
5
6namespace platform
7{
8typedef std::chrono::high_resolution_clock::time_point TimePoint;
9typedef std::chrono::high_resolution_clock::duration Duration;
10
11class PerformanceCounter
12{
13public:
14    static inline TimePoint now() { return std::chrono::high_resolution_clock::now(); }
15    static inline Duration getElapsedTime(TimePoint counter) { return now() - counter; }
16    static inline float getElapsedTimeInSeconds(TimePoint counter)
17    {
18        return (float)toSeconds(now() - counter);
19    }
20    static inline double toSeconds(Duration duration)
21    {
22        return std::chrono::duration<float>(duration).count();
23    }
24};
25} // namespace platform
26
27#endif