ArmNN
 21.08
ProfilingEvent.cpp
Go to the documentation of this file.
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 {
11 Event::Event(const std::string& eventName,
12  IProfiler* profiler,
13  Event* parent,
14  const BackendId backendId,
15  std::vector<InstrumentPtr>&& instruments,
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 
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 
36 Event::~Event() noexcept
37 {
38 }
39 
41 {
42  for (auto& instrument : m_Instruments)
43  {
44  instrument->Start();
45  }
46 }
47 
49 {
50  for (auto& instrument : m_Instruments)
51  {
52  instrument->Stop();
53  }
54 }
55 
56 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 
69 const std::string& Event::GetName() const
70 {
71  return m_EventName;
72 }
73 
75 {
76  return m_Profiler;
77 }
78 
80 {
81  return m_Parent;
82 }
83 
85 {
86  return m_BackendId;
87 }
88 
90 {
91  return m_ProfilingGuid;
92 }
93 
94 
95 Event& Event::operator=(Event&& other) noexcept
96 {
97  if (this == &other)
98  {
99  return *this;
100  }
101 
102  m_EventName = other.m_EventName;
103  m_Profiler = other.m_Profiler;
104  m_Parent = other.m_Parent;
105  m_BackendId = other.m_BackendId;
106  m_ProfilingGuid = other.m_ProfilingGuid;
107  other.m_Profiler = nullptr;
108  other.m_Parent = nullptr;
109  return *this;
110 }
111 
112 } // namespace armnn
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
Event(const std::string &eventName, IProfiler *profiler, Event *parent, const BackendId backendId, std::vector< InstrumentPtr > &&instrument, const Optional< profiling::ProfilingGuid > guid)
~Event() noexcept
Destructor.
const std::string & GetName() const
Get the name of the event.
Copyright (c) 2021 ARM Limited and Contributors.
void Start()
Start the Event.
Optional< profiling::ProfilingGuid > GetProfilingGuid() const
Get the associated profiling GUID if the event is a workload.
void Stop()
Stop the Event.
Event & operator=(const Event &other)=delete
Assignment operator.
BackendId GetBackendId() const
Get the backend id of the event.
const std::vector< Measurement > GetMeasurements() const
Get the recorded measurements calculated between Start() and Stop()
const IProfiler * GetProfiler() const
Get the pointer of the profiler associated with this event.
const Event * GetParentEvent() const
Get the pointer of the parent event.