telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "WallClockTimer.hpp" |
| 7 | |
| 8 | namespace armnn |
| 9 | { |
| 10 | |
| 11 | const std::string WallClockTimer::WALL_CLOCK_TIME ("Wall clock time"); |
| 12 | const std::string WallClockTimer::WALL_CLOCK_TIME_START(WallClockTimer::WALL_CLOCK_TIME + " (Start)"); |
| 13 | const std::string WallClockTimer::WALL_CLOCK_TIME_STOP (WallClockTimer::WALL_CLOCK_TIME + " (Stop)"); |
| 14 | |
| 15 | const char* WallClockTimer::GetName() const |
| 16 | { |
| 17 | return "WallClockTimer"; |
| 18 | } |
| 19 | |
| 20 | void WallClockTimer::Start() |
| 21 | { |
| 22 | m_Start = clock::now(); |
| 23 | } |
| 24 | |
| 25 | void WallClockTimer::Stop() |
| 26 | { |
| 27 | m_Stop = clock::now(); |
| 28 | } |
| 29 | |
| 30 | std::vector<Measurement> WallClockTimer::GetMeasurements() const |
| 31 | { |
Nina Drozd | 2d9dd36 | 2018-09-27 11:53:34 +0100 | [diff] [blame] | 32 | const auto delta = std::chrono::duration<double, std::micro>(m_Stop - m_Start); |
| 33 | const auto startTimeMs = std::chrono::duration<double, std::micro>(m_Start.time_since_epoch()); |
| 34 | const auto stopTimeMs = std::chrono::duration<double, std::micro>(m_Stop.time_since_epoch()); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 35 | |
Nina Drozd | 2d9dd36 | 2018-09-27 11:53:34 +0100 | [diff] [blame] | 36 | return { { WALL_CLOCK_TIME, delta.count(), Measurement::Unit::TIME_US }, |
| 37 | { WALL_CLOCK_TIME_START, startTimeMs.count(), Measurement::Unit::TIME_US }, |
| 38 | { WALL_CLOCK_TIME_STOP, stopTimeMs.count(), Measurement::Unit::TIME_US } }; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | } //namespace armnn |