diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-06-07 16:55:07 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2019-06-11 10:18:33 +0000 |
commit | e9e1878cb94e45ba71303a8ceda5bc523997fde4 (patch) | |
tree | 1ad3bd1d8083ad3f9a267aeb015636d0ef8e9650 /src | |
parent | 689471877bc6ae66489cbfa8734ce4f1ab085ab5 (diff) | |
download | armnn-e9e1878cb94e45ba71303a8ceda5bc523997fde4.tar.gz |
IVGCVSW-3253 Refactor MonotonicClockRaw in WallClockTimer
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: I759aaeff4e543c36047698716bd99bac4e4092d3
Diffstat (limited to 'src')
-rw-r--r-- | src/armnn/WallClockTimer.hpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/armnn/WallClockTimer.hpp b/src/armnn/WallClockTimer.hpp index 197ad7d1b7..ff17d79e92 100644 --- a/src/armnn/WallClockTimer.hpp +++ b/src/armnn/WallClockTimer.hpp @@ -11,25 +11,27 @@ namespace armnn { -// Clock class that uses the same timestamp function as the Mali DDK where possible. -class monotonic_clock_raw { +#if defined(CLOCK_MONOTONIC_RAW) && defined(__unix__) +#define USE_CLOCK_MONOTONIC_RAW 1 +#else +#define USE_CLOCK_MONOTONIC_RAW 0 +#endif + +#if USE_CLOCK_MONOTONIC_RAW +class MonotonicClockRaw +{ public: - using duration = std::chrono::nanoseconds; - using time_point = std::chrono::time_point<monotonic_clock_raw, duration>; + using duration = std::chrono::nanoseconds; + using time_point = std::chrono::time_point<MonotonicClockRaw, duration>; - static std::chrono::time_point<monotonic_clock_raw, std::chrono::nanoseconds> now() noexcept + static std::chrono::time_point<MonotonicClockRaw, std::chrono::nanoseconds> now() noexcept { -#if defined(__unix__) timespec ts; clock_gettime(CLOCK_MONOTONIC_RAW, &ts); return time_point(std::chrono::nanoseconds(ts.tv_sec * 1000000000 + ts.tv_nsec)); -#else - // On other platforms we have to make do with the standard C++ API, which may not exactly match - // the Mali DDK. - return std::chrono::time_point<monotonic_clock_raw, std::chrono::nanoseconds>(); -#endif } }; +#endif // Implementation of an instrument to measure elapsed wall-clock time in microseconds. class WallClockTimer : public Instrument @@ -51,8 +53,8 @@ public: // Get the recorded measurements std::vector<Measurement> GetMeasurements() const override; -#if defined(CLOCK_MONOTONIC_RAW) - using clock = monotonic_clock_raw; +#if USE_CLOCK_MONOTONIC_RAW + using clock = MonotonicClockRaw; #else using clock = std::chrono::steady_clock; #endif |