diff options
| author | 2015-02-15 15:49:27 -0200 | |
|---|---|---|
| committer | 2015-03-01 21:47:14 -0300 | |
| commit | dc8a3f8bc842df1b3eeeb5a283556ac644ab3183 (patch) | |
| tree | 82bc4d610bd0b77ba6f2ac4e514e68d1c251b251 /src/common/profiler.h | |
| parent | Add profiling infrastructure and widget (diff) | |
| download | yuzu-dc8a3f8bc842df1b3eeeb5a283556ac644ab3183.tar.gz yuzu-dc8a3f8bc842df1b3eeeb5a283556ac644ab3183.tar.xz yuzu-dc8a3f8bc842df1b3eeeb5a283556ac644ab3183.zip | |
Profiler: Implement QPCClock to get better precision on Win32
MSVC 2013 (at least) doesn't use QueryPerformanceCounter to implement
std::chrono::high_resolution_clock, so it has bad precision. Manually
implementing our own clock type using it works around this for now.
Diffstat (limited to 'src/common/profiler.h')
| -rw-r--r-- | src/common/profiler.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/common/profiler.h b/src/common/profiler.h index 53c4f6eaf..3e967b4bc 100644 --- a/src/common/profiler.h +++ b/src/common/profiler.h | |||
| @@ -18,8 +18,26 @@ namespace Profiling { | |||
| 18 | #define ENABLE_PROFILING 1 | 18 | #define ENABLE_PROFILING 1 |
| 19 | #endif | 19 | #endif |
| 20 | 20 | ||
| 21 | using Duration = std::chrono::nanoseconds; | 21 | #if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013 |
| 22 | // MSVC up to 2013 doesn't use QueryPerformanceCounter for high_resolution_clock, so it has bad | ||
| 23 | // precision. We manually implement a clock based on QPC to get good results. | ||
| 24 | |||
| 25 | struct QPCClock { | ||
| 26 | using duration = std::chrono::microseconds; | ||
| 27 | using time_point = std::chrono::time_point<QPCClock>; | ||
| 28 | using rep = duration::rep; | ||
| 29 | using period = duration::period; | ||
| 30 | static const bool is_steady = false; | ||
| 31 | |||
| 32 | static time_point now(); | ||
| 33 | }; | ||
| 34 | |||
| 35 | using Clock = QPCClock; | ||
| 36 | #else | ||
| 22 | using Clock = std::chrono::high_resolution_clock; | 37 | using Clock = std::chrono::high_resolution_clock; |
| 38 | #endif | ||
| 39 | |||
| 40 | using Duration = Clock::duration; | ||
| 23 | 41 | ||
| 24 | /** | 42 | /** |
| 25 | * Represents a timing category that measured time can be accounted towards. Should be declared as a | 43 | * Represents a timing category that measured time can be accounted towards. Should be declared as a |