2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
8 #include "Instrument.hpp"
14 // Clock class that uses the same timestamp function as the Mali DDK.
15 class monotonic_clock_raw {
17 using duration = std::chrono::nanoseconds;
18 using time_point = std::chrono::time_point<monotonic_clock_raw, duration>;
20 static std::chrono::time_point<monotonic_clock_raw, std::chrono::nanoseconds> now() noexcept
23 clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
24 return time_point(std::chrono::nanoseconds(ts.tv_sec*1000000000 + ts.tv_nsec));
28 // Implementation of an instrument to measure elapsed wall-clock time in milliseconds.
29 class WallClockTimer : public Instrument
32 // Construct a Wall Clock Timer
33 WallClockTimer() = default;
34 ~WallClockTimer() = default;
36 // Start the Wall clock timer
37 void Start() override;
39 // Stop the Wall clock timer
42 // Get the name of the timer
43 const char* GetName() const override;
45 // Get the recorded measurements
46 std::vector<Measurement> GetMeasurements() const override;
48 #if defined(CLOCK_MONOTONIC_RAW)
49 using clock = monotonic_clock_raw;
51 using clock = std::chrono::steady_clock;
54 static const std::string WALL_CLOCK_TIME;
55 static const std::string WALL_CLOCK_TIME_START;
56 static const std::string WALL_CLOCK_TIME_STOP;
59 clock::time_point m_Start;
60 clock::time_point m_Stop;