1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "Profiling.hpp"
7 #include "ProfilingEvent.hpp"
8
9 namespace armnn
10 {
Event(const std::string & eventName,Profiler * profiler,Event * parent,const BackendId backendId,std::vector<InstrumentPtr> && instruments)11 Event::Event(const std::string& eventName,
12 Profiler* profiler,
13 Event* parent,
14 const BackendId backendId,
15 std::vector<InstrumentPtr>&& instruments)
16 : m_EventName(eventName)
17 , m_Profiler(profiler)
18 , m_Parent(parent)
19 , m_BackendId(backendId)
20 , m_Instruments(std::move(instruments))
21 {
22 }
23
Event(Event && other)24 Event::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_BackendId(other.m_BackendId)
29 , m_Instruments(std::move(other.m_Instruments))
30
31 {
32 }
33
~Event()34 Event::~Event() noexcept
35 {
36 }
37
Start()38 void Event::Start()
39 {
40 for (auto& instrument : m_Instruments)
41 {
42 instrument->Start();
43 }
44 }
45
Stop()46 void Event::Stop()
47 {
48 for (auto& instrument : m_Instruments)
49 {
50 instrument->Stop();
51 }
52 }
53
GetMeasurements() const54 const 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
GetName() const67 const std::string& Event::GetName() const
68 {
69 return m_EventName;
70 }
71
GetProfiler() const72 const Profiler* Event::GetProfiler() const
73 {
74 return m_Profiler;
75 }
76
GetParentEvent() const77 const Event* Event::GetParentEvent() const
78 {
79 return m_Parent;
80 }
81
GetBackendId() const82 BackendId Event::GetBackendId() const
83 {
84 return m_BackendId;
85 }
86
operator =(Event && other)87 Event& 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_BackendId = other.m_BackendId;
98 other.m_Profiler = nullptr;
99 other.m_Parent = nullptr;
100 return *this;
101 }
102
103 } // namespace armnn
104