ArmNN
 20.02
TimelineUtilityMethodsTests.cpp File Reference
#include "ProfilingMocks.hpp"
#include "ProfilingTestUtils.hpp"
#include <SendTimelinePacket.hpp>
#include <TimelineUtilityMethods.hpp>
#include <LabelsAndEventClasses.hpp>
#include <ProfilingService.hpp>
#include <memory>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (CreateTypedLabelTest)
 
 BOOST_AUTO_TEST_CASE (SendWellKnownLabelsAndEventClassesTest)
 
 BOOST_AUTO_TEST_CASE (CreateNamedTypedChildEntityTest)
 
 BOOST_AUTO_TEST_CASE (DeclareLabelTest)
 
 BOOST_AUTO_TEST_CASE (CreateNameTypeEntityInvalidTest)
 
 BOOST_AUTO_TEST_CASE (CreateNameTypeEntityTest)
 
 BOOST_AUTO_TEST_CASE (RecordEventTest)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( CreateTypedLabelTest  )

Definition at line 23 of file TimelineUtilityMethodsTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), ProfilingService::Instance(), armnn::profiling::LabelLink, MockBufferManager::MarkRead(), ProfilingService::NextGuid(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), and VerifyTimelineRelationshipBinaryPacketData().

24 {
25  MockBufferManager mockBufferManager(1024);
26  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
27  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
28 
29  // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
30  ProfilingService::Instance().NextGuid();
31 
32  ProfilingGuid entityGuid(123);
33  const std::string entityName = "some entity";
34  ProfilingStaticGuid labelTypeGuid(456);
35 
36  BOOST_CHECK_NO_THROW(timelineUtilityMethods.MarkEntityWithLabel(entityGuid, entityName, labelTypeGuid));
37 
38  // Commit all packets at once
39  timelineUtilityMethods.Commit();
40 
41  // Get the readable buffer
42  auto readableBuffer = mockBufferManager.GetReadableBuffer();
43  BOOST_CHECK(readableBuffer != nullptr);
44  unsigned int size = readableBuffer->GetSize();
45  BOOST_CHECK(size == 100);
46  const unsigned char* readableData = readableBuffer->GetReadableData();
47  BOOST_CHECK(readableData != nullptr);
48 
49  // Utils
50  unsigned int offset = 0;
51 
52  // Verify Header
53  VerifyTimelineHeaderBinary(readableData, offset, 92);
54 
55  // First dataset sent: TimelineLabelBinaryPacket
56  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset);
57 
58  // Second dataset sent: TimelineRelationshipBinaryPacket
59  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
60  EmptyOptional(),
61  entityGuid,
62  EmptyOptional(),
63  readableData,
64  offset);
65 
66  // Third dataset sent: TimelineRelationshipBinaryPacket
67  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
68  EmptyOptional(),
69  EmptyOptional(),
70  labelTypeGuid,
71  readableData,
72  offset);
73 
74  // Mark the buffer as read
75  mockBufferManager.MarkRead(readableBuffer);
76 }
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( SendWellKnownLabelsAndEventClassesTest  )

Definition at line 78 of file TimelineUtilityMethodsTests.cpp.

References LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, LabelsAndEventClasses::BACKENDID_GUID, LabelsAndEventClasses::BACKENDID_LABEL, BOOST_CHECK(), LabelsAndEventClasses::CONNECTION, LabelsAndEventClasses::CONNECTION_GUID, MockBufferManager::GetReadableBuffer(), LabelsAndEventClasses::INDEX_GUID, LabelsAndEventClasses::INDEX_LABEL, LabelsAndEventClasses::INFERENCE, LabelsAndEventClasses::INFERENCE_GUID, LabelsAndEventClasses::LAYER, LabelsAndEventClasses::LAYER_GUID, MockBufferManager::MarkRead(), LabelsAndEventClasses::NAME_GUID, LabelsAndEventClasses::NAME_LABEL, LabelsAndEventClasses::NETWORK, LabelsAndEventClasses::NETWORK_GUID, LabelsAndEventClasses::TYPE_GUID, LabelsAndEventClasses::TYPE_LABEL, VerifyTimelineEventClassBinaryPacketData(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), LabelsAndEventClasses::WORKLOAD, LabelsAndEventClasses::WORKLOAD_EXECUTION, LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, and LabelsAndEventClasses::WORKLOAD_GUID.

79 {
80  MockBufferManager mockBufferManager(1024);
81  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
82  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
83 
84  BOOST_CHECK_NO_THROW(timelineUtilityMethods.SendWellKnownLabelsAndEventClasses());
85 
86  // Commit all packets at once
87  timelineUtilityMethods.Commit();
88 
89  // Get the readable buffer
90  auto readableBuffer = mockBufferManager.GetReadableBuffer();
91  BOOST_CHECK(readableBuffer != nullptr);
92  unsigned int size = readableBuffer->GetSize();
93  BOOST_TEST(size == 300);
94  const unsigned char* readableData = readableBuffer->GetReadableData();
95  BOOST_CHECK(readableData != nullptr);
96 
97  // Utils
98  unsigned int offset = 0;
99 
100  // Verify Header
101  VerifyTimelineHeaderBinary(readableData, offset, 292);
102 
103  // First "well-known" label: NAME
104  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::NAME_GUID,
105  LabelsAndEventClasses::NAME_LABEL,
106  readableData,
107  offset);
108 
109  // Second "well-known" label: TYPE
110  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::TYPE_GUID,
111  LabelsAndEventClasses::TYPE_LABEL,
112  readableData,
113  offset);
114 
115  // Third "well-known" label: INDEX
116  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::INDEX_GUID,
117  LabelsAndEventClasses::INDEX_LABEL,
118  readableData,
119  offset);
120 
121  // Forth "well-known" label: BACKENDID
122  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::BACKENDID_GUID,
123  LabelsAndEventClasses::BACKENDID_LABEL,
124  readableData,
125  offset);
126 
127  // Well-known types
128  // Layer
129  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::LAYER_GUID,
130  LabelsAndEventClasses::LAYER,
131  readableData,
132  offset);
133 
134  // Workload
135  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::WORKLOAD_GUID,
136  LabelsAndEventClasses::WORKLOAD,
137  readableData,
138  offset);
139 
140  // Network
141  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::NETWORK_GUID,
142  LabelsAndEventClasses::NETWORK,
143  readableData,
144  offset);
145 
146  // Connection
147  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::CONNECTION_GUID,
148  LabelsAndEventClasses::CONNECTION,
149  readableData,
150  offset);
151 
152  // Inference
153  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::INFERENCE_GUID,
154  LabelsAndEventClasses::INFERENCE,
155  readableData,
156  offset);
157 
158  // Workload Execution
159  VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID,
160  LabelsAndEventClasses::WORKLOAD_EXECUTION,
161  readableData,
162  offset);
163 
164  // First "well-known" event class: START OF LIFE
165  VerifyTimelineEventClassBinaryPacketData(LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS,
166  readableData,
167  offset);
168 
169  // Second "well-known" event class: END OF LIFE
170  VerifyTimelineEventClassBinaryPacketData(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS,
171  readableData,
172  offset);
173 
174  // Mark the buffer as read
175  mockBufferManager.MarkRead(readableBuffer);
176 }
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, const unsigned char *readableData, unsigned int &offset)

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( CreateNamedTypedChildEntityTest  )

Definition at line 178 of file TimelineUtilityMethodsTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), ProfilingService::Instance(), armnn::profiling::LabelLink, MockBufferManager::MarkRead(), LabelsAndEventClasses::NAME_GUID, ProfilingService::NextGuid(), armnn::profiling::RetentionLink, LabelsAndEventClasses::TYPE_GUID, VerifyTimelineEntityBinaryPacketData(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), and VerifyTimelineRelationshipBinaryPacketData().

179 {
180  MockBufferManager mockBufferManager(1024);
181  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
182  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
183 
184  ProfilingDynamicGuid childEntityGuid(0);
185  ProfilingGuid parentEntityGuid(123);
186  const std::string entityName = "some entity";
187  const std::string entityType = "some type";
188 
189  // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
190  ProfilingService::Instance().NextGuid();
191 
192  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, "", entityType),
194  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, entityName, ""),
196  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(
197  childEntityGuid, parentEntityGuid, "", entityType), InvalidArgumentException);
198  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(
199  childEntityGuid, parentEntityGuid, entityName, ""), InvalidArgumentException);
200 
201  BOOST_CHECK_NO_THROW(childEntityGuid = timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
202  entityName,
203  entityType));
204  BOOST_CHECK(childEntityGuid != ProfilingGuid(0));
205 
206  // Commit all packets at once
207  timelineUtilityMethods.Commit();
208 
209  // Get the readable buffer
210  auto readableBuffer = mockBufferManager.GetReadableBuffer();
211  BOOST_CHECK(readableBuffer != nullptr);
212  unsigned int size = readableBuffer->GetSize();
213  BOOST_CHECK(size == 236);
214  const unsigned char* readableData = readableBuffer->GetReadableData();
215  BOOST_CHECK(readableData != nullptr);
216 
217  // Utils
218  unsigned int offset = 0;
219 
220  // Verify Header
221  VerifyTimelineHeaderBinary(readableData, offset, 228);
222 
223  // First dataset sent: TimelineEntityBinaryPacket
224  VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset);
225 
226  // Second dataset sent: TimelineLabelBinaryPacket
227  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset);
228 
229  // Third dataset sent: TimelineRelationshipBinaryPacket
230  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
231  EmptyOptional(),
232  EmptyOptional(),
233  EmptyOptional(),
234  readableData,
235  offset);
236 
237  // Fourth dataset sent: TimelineRelationshipBinaryPacket
238  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
239  EmptyOptional(),
240  EmptyOptional(),
241  LabelsAndEventClasses::NAME_GUID,
242  readableData,
243  offset);
244 
245  // Fifth dataset sent: TimelineLabelBinaryPacket
246  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityType, readableData, offset);
247 
248  // Sixth dataset sent: TimelineRelationshipBinaryPacket
249  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
250  EmptyOptional(),
251  EmptyOptional(),
252  EmptyOptional(),
253  readableData,
254  offset);
255 
256  // Seventh dataset sent: TimelineRelationshipBinaryPacket
257  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
258  EmptyOptional(),
259  EmptyOptional(),
260  LabelsAndEventClasses::TYPE_GUID,
261  readableData,
262  offset);
263 
264  // Eighth dataset sent: TimelineRelationshipBinaryPacket
265  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink,
266  EmptyOptional(),
267  parentEntityGuid,
268  EmptyOptional(),
269  readableData,
270  offset);
271 
272  // Mark the buffer as read
273  mockBufferManager.MarkRead(readableBuffer);
274 }
void VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( DeclareLabelTest  )

Definition at line 276 of file TimelineUtilityMethodsTests.cpp.

References BOOST_CHECK(), ProfilingService::Instance(), and ProfilingService::NextGuid().

277 {
278  MockBufferManager mockBufferManager(1024);
279  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
280  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
281 
282  // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
283  ProfilingService::Instance().NextGuid();
284 
285  // Try declaring an invalid (empty) label
286  BOOST_CHECK_THROW(timelineUtilityMethods.DeclareLabel(""), InvalidArgumentException);
287 
288  // Try declaring an invalid (wrong SWTrace format) label
289  BOOST_CHECK_THROW(timelineUtilityMethods.DeclareLabel("inv@lid lab€l"), RuntimeException);
290 
291  // Declare a valid label
292  const std::string labelName = "valid label";
293  ProfilingGuid labelGuid = 0;
294  BOOST_CHECK_NO_THROW(labelGuid = timelineUtilityMethods.DeclareLabel(labelName));
295  BOOST_CHECK(labelGuid != ProfilingGuid(0));
296 
297  // Try adding the same label as before
298  ProfilingGuid newLabelGuid = 0;
299  BOOST_CHECK_NO_THROW(newLabelGuid = timelineUtilityMethods.DeclareLabel(labelName));
300  BOOST_CHECK(newLabelGuid != ProfilingGuid(0));
301  BOOST_CHECK(newLabelGuid == labelGuid);
302 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( CreateNameTypeEntityInvalidTest  )

Definition at line 304 of file TimelineUtilityMethodsTests.cpp.

References ProfilingService::Instance(), and ProfilingService::NextGuid().

305 {
306  MockBufferManager mockBufferManager(1024);
307  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
308  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
309 
310  // Invalid name
311  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity("", "Type"), InvalidArgumentException);
312 
313  // Invalid type
314  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity("Name", ""), InvalidArgumentException);
315 
316  ProfilingDynamicGuid guid = ProfilingService::Instance().NextGuid();
317 
318  // CreatedNamedTypedEntity with Guid - Invalid name
319  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity(guid, "", "Type"),
321 
322  // CreatedNamedTypedEntity with Guid - Invalid type
323  BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity(guid, "Name", ""),
325 
326 }
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( CreateNameTypeEntityTest  )

Definition at line 328 of file TimelineUtilityMethodsTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), ProfilingService::Instance(), armnn::profiling::LabelLink, MockBufferManager::MarkRead(), LabelsAndEventClasses::NAME_GUID, ProfilingService::NextGuid(), LabelsAndEventClasses::TYPE_GUID, VerifyTimelineEntityBinaryPacketData(), VerifyTimelineHeaderBinary(), VerifyTimelineLabelBinaryPacketData(), and VerifyTimelineRelationshipBinaryPacketData().

329 {
330  MockBufferManager mockBufferManager(1024);
331  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
332  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
333 
334  const std::string entityName = "Entity0";
335  const std::string entityType = "Type0";
336 
337  // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
338  ProfilingService::Instance().NextGuid();
339 
340  ProfilingDynamicGuid guid = timelineUtilityMethods.CreateNamedTypedEntity(entityName, entityType);
341  BOOST_CHECK(guid != ProfilingGuid(0));
342 
343  // Commit all packets at once
344  timelineUtilityMethods.Commit();
345 
346  // Get the readable buffer
347  auto readableBuffer = mockBufferManager.GetReadableBuffer();
348  BOOST_CHECK(readableBuffer != nullptr);
349  unsigned int size = readableBuffer->GetSize();
350  BOOST_CHECK(size == 196);
351  const unsigned char* readableData = readableBuffer->GetReadableData();
352  BOOST_CHECK(readableData != nullptr);
353 
354  // Utils
355  unsigned int offset = 0;
356 
357  // Verify Header
358  VerifyTimelineHeaderBinary(readableData, offset, 188);
359 
360  // First dataset sent: TimelineEntityBinaryPacket
361  VerifyTimelineEntityBinaryPacketData(guid, readableData, offset);
362 
363  // Packets for Name Entity
364  // First dataset sent: TimelineLabelBinaryPacket
365  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset);
366 
367  // Second dataset sent: TimelineRelationshipBinaryPacket
368  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
369  EmptyOptional(),
370  EmptyOptional(),
371  EmptyOptional(),
372  readableData,
373  offset);
374 
375  // Third dataset sent: TimelineRelationshipBinaryPacket
376  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
377  EmptyOptional(),
378  EmptyOptional(),
379  LabelsAndEventClasses::NAME_GUID,
380  readableData,
381  offset);
382 
383  // Packets for Type Entity
384  // First dataset sent: TimelineLabelBinaryPacket
385  VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityType, readableData, offset);
386 
387  // Second dataset sent: TimelineRelationshipBinaryPacket
388  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
389  EmptyOptional(),
390  EmptyOptional(),
391  EmptyOptional(),
392  readableData,
393  offset);
394 
395  // Third dataset sent: TimelineRelationshipBinaryPacket
396  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink,
397  EmptyOptional(),
398  EmptyOptional(),
399  LabelsAndEventClasses::TYPE_GUID,
400  readableData,
401  offset);
402 
403  // Mark the buffer as read
404  mockBufferManager.MarkRead(readableBuffer);
405 }
void VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294
void VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( RecordEventTest  )

Definition at line 407 of file TimelineUtilityMethodsTests.cpp.

References BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), armnn::profiling::DataLink, armnn::profiling::ExecutionLink, MockBufferManager::GetReadableBuffer(), ProfilingService::Instance(), MockBufferManager::MarkRead(), ProfilingService::NextGuid(), VerifyTimelineEventBinaryPacket(), VerifyTimelineHeaderBinary(), and VerifyTimelineRelationshipBinaryPacketData().

408 {
409  MockBufferManager mockBufferManager(1024);
410  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
411  TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
412  // Generate first guid to ensure that the named typed entity guid is not 0 on local single test.
413  ProfilingService::Instance().NextGuid();
414 
415  ProfilingGuid entityGuid(123);
416  ProfilingStaticGuid eventClassGuid(456);
417  ProfilingDynamicGuid eventGuid(0);
418  BOOST_CHECK_NO_THROW(eventGuid = timelineUtilityMethods.RecordEvent(entityGuid, eventClassGuid));
419  BOOST_CHECK(eventGuid != ProfilingGuid(0));
420 
421  // Commit all packets at once
422  timelineUtilityMethods.Commit();
423 
424  // Get the readable buffer
425  auto readableBuffer = mockBufferManager.GetReadableBuffer();
426  BOOST_CHECK(readableBuffer != nullptr);
427  unsigned int size = readableBuffer->GetSize();
428  BOOST_CHECK(size == 100);
429  const unsigned char* readableData = readableBuffer->GetReadableData();
430  BOOST_CHECK(readableData != nullptr);
431 
432  // Utils
433  unsigned int offset = 0;
434 
435  // Verify Header
436  VerifyTimelineHeaderBinary(readableData, offset, 92);
437 
438  // First dataset sent: TimelineEntityBinaryPacket
440 
441  // Second dataset sent: TimelineRelationshipBinaryPacket
442  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink,
443  EmptyOptional(),
444  entityGuid,
445  EmptyOptional(),
446  readableData,
447  offset);
448 
449  // Third dataset sent: TimelineRelationshipBinaryPacket
450  VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink,
451  EmptyOptional(),
452  eventGuid,
453  eventClassGuid,
454  readableData,
455  offset);
456 
457  // Mark the buffer as read
458  mockBufferManager.MarkRead(readableBuffer);
459 }
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, const unsigned char *readableData, unsigned int &offset)
void VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< std::thread::id > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)