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