ArmNN
 20.02
ProfilingEventTest.cpp File Reference
#include <boost/test/unit_test.hpp>
#include "ProfilingEvent.hpp"
#include "Profiling.hpp"
#include <thread>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (ProfilingEventTest)
 
 BOOST_AUTO_TEST_CASE (ProfilingEventTestOnGpuAcc)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( ProfilingEventTest  )

Definition at line 17 of file ProfilingEventTest.cpp.

References BOOST_CHECK(), armnn::CpuAcc, ProfilerManager::GetInstance(), Event::GetMeasurements(), Event::GetName(), Event::GetParentEvent(), ProfilerManager::GetProfiler(), Event::Start(), and Event::Stop().

18 {
19  // Get a reference to the profiler manager.
21 
22  const char* eventName = "EventName";
23 
24  Event::Instruments insts1;
25  insts1.emplace_back(std::make_unique<WallClockTimer>());
26  Event testEvent(eventName,
27  nullptr,
28  nullptr,
29  BackendId(),
30  std::move(insts1));
31 
32  BOOST_CHECK_EQUAL(testEvent.GetName(), "EventName");
33 
34  // start the timer - outer
35  testEvent.Start();
36 
37  // wait for 10 microseconds
38  std::this_thread::sleep_for(std::chrono::microseconds(10));
39 
40  // stop the timer - outer
41  testEvent.Stop();
42 
43  BOOST_CHECK_GE(testEvent.GetMeasurements().front().m_Value, 10.0);
44 
45  // create a sub event with CpuAcc
46  BackendId cpuAccBackendId(Compute::CpuAcc);
47  Event::Instruments insts2;
48  insts2.emplace_back(std::make_unique<WallClockTimer>());
49  Event testEvent2(eventName,
50  profileManager.GetProfiler(),
51  &testEvent,
52  cpuAccBackendId,
53  std::move(insts2));
54 
55  BOOST_CHECK_EQUAL(&testEvent, testEvent2.GetParentEvent());
56  BOOST_CHECK_EQUAL(profileManager.GetProfiler(), testEvent2.GetProfiler());
57  BOOST_CHECK(cpuAccBackendId == testEvent2.GetBackendId());
58 }
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:487
std::vector< InstrumentPtr > Instruments
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
Profiler * GetProfiler()
Definition: Profiling.cpp:499

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( ProfilingEventTestOnGpuAcc  )

Definition at line 60 of file ProfilingEventTest.cpp.

References BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), ProfilerManager::GetInstance(), Event::GetMeasurements(), Event::GetName(), Event::GetParentEvent(), ProfilerManager::GetProfiler(), armnn::GpuAcc, Event::Start(), and Event::Stop().

61 {
62  // Get a reference to the profiler manager.
64 
65  const char* eventName = "GPUEvent";
66 
67  Event::Instruments insts1;
68  insts1.emplace_back(std::make_unique<WallClockTimer>());
69  Event testEvent(eventName,
70  nullptr,
71  nullptr,
72  BackendId(),
73  std::move(insts1));
74 
75  BOOST_CHECK_EQUAL(testEvent.GetName(), "GPUEvent");
76 
77  // start the timer - outer
78  testEvent.Start();
79 
80  // wait for 10 microseconds
81  std::this_thread::sleep_for(std::chrono::microseconds(10));
82 
83  // stop the timer - outer
84  testEvent.Stop();
85 
86  BOOST_CHECK_GE(testEvent.GetMeasurements().front().m_Value, 10.0);
87 
88  // create a sub event
89  BackendId gpuAccBackendId(Compute::GpuAcc);
90  Event::Instruments insts2;
91  insts2.emplace_back(std::make_unique<WallClockTimer>());
92  Event testEvent2(eventName,
93  profileManager.GetProfiler(),
94  &testEvent,
95  gpuAccBackendId,
96  std::move(insts2));
97 
98  BOOST_CHECK_EQUAL(&testEvent, testEvent2.GetParentEvent());
99  BOOST_CHECK_EQUAL(profileManager.GetProfiler(), testEvent2.GetProfiler());
100  BOOST_CHECK(gpuAccBackendId == testEvent2.GetBackendId());
101 }
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
static ProfilerManager & GetInstance()
Definition: Profiling.cpp:487
std::vector< InstrumentPtr > Instruments
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
Profiler * GetProfiler()
Definition: Profiling.cpp:499