blob: 55e931a16384fa4b0f75b802436500a8dadbf789 [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 "Profiling.hpp"
7#include "ProfilingEvent.hpp"
8
9namespace armnn
10{
11Event::Event(const std::string& eventName,
12 Profiler* profiler,
13 Event* parent,
14 const Compute computeDevice,
15 std::vector<InstrumentPtr>&& instruments)
16 : m_EventName(eventName)
17 , m_Profiler(profiler)
18 , m_Parent(parent)
19 , m_ComputeDevice(computeDevice)
20 , m_Instruments(std::move(instruments))
21{
22}
23
24Event::Event(Event&& other) noexcept
25 : m_EventName(std::move(other.m_EventName))
26 , m_Profiler(other.m_Profiler)
27 , m_Parent(other.m_Parent)
28 , m_ComputeDevice(other.m_ComputeDevice)
29 , m_Instruments(std::move(other.m_Instruments))
30
31{
32}
33
34Event::~Event() noexcept
35{
36}
37
38void Event::Start()
39{
40 for (auto& instrument : m_Instruments)
41 {
42 instrument->Start();
43 }
44}
45
46void Event::Stop()
47{
48 for (auto& instrument : m_Instruments)
49 {
50 instrument->Stop();
51 }
52}
53
54const std::vector<Measurement> Event::GetMeasurements() const
55{
56 std::vector<Measurement> measurements;
57 for (auto& instrument : m_Instruments)
58 {
59 for (auto& measurement : instrument->GetMeasurements())
60 {
61 measurements.emplace_back(std::move(measurement));
62 }
63 }
64 return measurements;
65}
66
67const std::string& Event::GetName() const
68{
69 return m_EventName;
70}
71
72const Profiler* Event::GetProfiler() const
73{
74 return m_Profiler;
75}
76
77const Event* Event::GetParentEvent() const
78{
79 return m_Parent;
80}
81
82Compute Event::GetComputeDevice() const
83{
84 return m_ComputeDevice;
85}
86
87Event& Event::operator=(Event&& other) noexcept
88{
89 if (this == &other)
90 {
91 return *this;
92 }
93
94 m_EventName = other.m_EventName;
95 m_Profiler = other.m_Profiler;
96 m_Parent = other.m_Parent;
97 m_ComputeDevice = other.m_ComputeDevice;
98 other.m_Profiler = nullptr;
99 other.m_Parent = nullptr;
100 return *this;
101}
102
103} // namespace armnn