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,IProfiler * profiler,Event * parent,const BackendId backendId,std::vector<InstrumentPtr> && instruments,const Optional<arm::pipe::ProfilingGuid> guid)11 Event::Event(const std::string& eventName,
12 IProfiler* profiler,
13 Event* parent,
14 const BackendId backendId,
15 std::vector<InstrumentPtr>&& instruments,
16 const Optional<arm::pipe::ProfilingGuid> guid)
17 : m_EventName(eventName)
18 , m_Profiler(profiler)
19 , m_Parent(parent)
20 , m_BackendId(backendId)
21 , m_Instruments(std::move(instruments))
22 , m_ProfilingGuid(guid)
23 {
24 }
25
Event(Event && other)26 Event::Event(Event&& other) noexcept
27 : m_EventName(std::move(other.m_EventName))
28 , m_Profiler(other.m_Profiler)
29 , m_Parent(other.m_Parent)
30 , m_BackendId(other.m_BackendId)
31 , m_Instruments(std::move(other.m_Instruments))
32 , m_ProfilingGuid(other.m_ProfilingGuid)
33 {
34 }
35
~Event()36 Event::~Event() noexcept
37 {
38 }
39
Start()40 void Event::Start()
41 {
42 for (auto& instrument : m_Instruments)
43 {
44 instrument->Start();
45 }
46 }
47
Stop()48 void Event::Stop()
49 {
50 for (auto& instrument : m_Instruments)
51 {
52 instrument->Stop();
53 }
54 }
55
GetMeasurements() const56 const std::vector<Measurement> Event::GetMeasurements() const
57 {
58 std::vector<Measurement> measurements;
59 for (auto& instrument : m_Instruments)
60 {
61 for (auto& measurement : instrument->GetMeasurements())
62 {
63 measurements.emplace_back(std::move(measurement));
64 }
65 }
66 return measurements;
67 }
68
GetInstruments() const69 const std::vector<Event::InstrumentPtr>& Event::GetInstruments() const
70 {
71 return m_Instruments;
72 }
73
GetName() const74 const std::string& Event::GetName() const
75 {
76 return m_EventName;
77 }
78
GetProfiler() const79 const IProfiler* Event::GetProfiler() const
80 {
81 return m_Profiler;
82 }
83
GetParentEvent() const84 const Event* Event::GetParentEvent() const
85 {
86 return m_Parent;
87 }
88
GetBackendId() const89 BackendId Event::GetBackendId() const
90 {
91 return m_BackendId;
92 }
93
GetProfilingGuid() const94 Optional<arm::pipe::ProfilingGuid> Event::GetProfilingGuid() const
95 {
96 return m_ProfilingGuid;
97 }
98
99
operator =(Event && other)100 Event& Event::operator=(Event&& other) noexcept
101 {
102 if (this == &other)
103 {
104 return *this;
105 }
106
107 m_EventName = other.m_EventName;
108 m_Profiler = other.m_Profiler;
109 m_Parent = other.m_Parent;
110 m_BackendId = other.m_BackendId;
111 m_ProfilingGuid = other.m_ProfilingGuid;
112 other.m_Profiler = nullptr;
113 other.m_Parent = nullptr;
114 return *this;
115 }
116
117 } // namespace armnn
118