blob: 570b69077ab6ec0b15e7d5c4e27d5556656fca83 [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
5
6#include "WallClockTimer.hpp"
7
8namespace armnn
9{
10
11const std::string WallClockTimer::WALL_CLOCK_TIME ("Wall clock time");
12const std::string WallClockTimer::WALL_CLOCK_TIME_START(WallClockTimer::WALL_CLOCK_TIME + " (Start)");
13const std::string WallClockTimer::WALL_CLOCK_TIME_STOP (WallClockTimer::WALL_CLOCK_TIME + " (Stop)");
14
15const char* WallClockTimer::GetName() const
16{
17 return "WallClockTimer";
18}
19
20void WallClockTimer::Start()
21{
22 m_Start = clock::now();
23}
24
25void WallClockTimer::Stop()
26{
27 m_Stop = clock::now();
28}
29
30std::vector<Measurement> WallClockTimer::GetMeasurements() const
31{
Nina Drozd2d9dd362018-09-27 11:53:34 +010032 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());
telsoa01c577f2c2018-08-31 09:22:23 +010035
Nina Drozd2d9dd362018-09-27 11:53:34 +010036 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 } };
telsoa01c577f2c2018-08-31 09:22:23 +010039}
40
41} //namespace armnn