ArmNN
 20.11
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  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 
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 
34 Event::~Event() noexcept
35 {
36 }
37 
39 {
40  for (auto& instrument : m_Instruments)
41  {
42  instrument->Start();
43  }
44 }
45 
47 {
48  for (auto& instrument : m_Instruments)
49  {
50  instrument->Stop();
51  }
52 }
53 
54 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 
67 const std::string& Event::GetName() const
68 {
69  return m_EventName;
70 }
71 
73 {
74  return m_Profiler;
75 }
76 
78 {
79  return m_Parent;
80 }
81 
83 {
84  return m_BackendId;
85 }
86 
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
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
const Profiler * GetProfiler() const
Get the pointer of the profiler associated with this event.
~Event() noexcept
Destructor.
const std::string & GetName() const
Get the name of the event.
Copyright (c) 2020 ARM Limited.
void Start()
Start the Event.
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()
Event(const std::string &eventName, Profiler *profiler, Event *parent, const BackendId backendId, std::vector< InstrumentPtr > &&instrument)
const Event * GetParentEvent() const
Get the pointer of the parent event.