29 TEST_CASE(
"CreateTypedLabelTest")
33 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
35 arm::pipe::ARMNN_SOFTWARE_INFO,
36 arm::pipe::ARMNN_SOFTWARE_VERSION,
37 arm::pipe::ARMNN_HARDWARE_VERSION);
39 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
40 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
43 profilingService.NextGuid();
45 ProfilingGuid entityGuid(123);
46 const std::string entityName =
"some entity";
47 ProfilingStaticGuid labelTypeGuid(456);
49 CHECK_NOTHROW(timelineUtilityMethods.MarkEntityWithLabel(entityGuid, entityName, labelTypeGuid));
52 timelineUtilityMethods.Commit();
55 auto readableBuffer = mockBufferManager.GetReadableBuffer();
56 CHECK(readableBuffer !=
nullptr);
57 unsigned int size = readableBuffer->GetSize();
59 const unsigned char* readableData = readableBuffer->GetReadableData();
60 CHECK(readableData !=
nullptr);
63 unsigned int offset = 0;
73 arm::pipe::EmptyOptional(),
75 arm::pipe::EmptyOptional(),
81 mockBufferManager.MarkRead(readableBuffer);
84 TEST_CASE(
"SendWellKnownLabelsAndEventClassesTest")
88 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
90 arm::pipe::ARMNN_SOFTWARE_INFO,
91 arm::pipe::ARMNN_SOFTWARE_VERSION,
92 arm::pipe::ARMNN_HARDWARE_VERSION);
93 SendTimelinePacket sendTimelinePacket(mockBufferManager);
95 CHECK_NOTHROW(TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(sendTimelinePacket));
98 auto readableBuffer = mockBufferManager.GetReadableBuffer();
99 CHECK(readableBuffer !=
nullptr);
100 unsigned int size = readableBuffer->GetSize();
102 const unsigned char* readableData = readableBuffer->GetReadableData();
103 CHECK(readableData !=
nullptr);
106 unsigned int offset = 0;
113 LabelsAndEventClasses::NAME_LABEL,
119 LabelsAndEventClasses::TYPE_LABEL,
125 LabelsAndEventClasses::INDEX_LABEL,
131 LabelsAndEventClasses::BACKENDID_LABEL,
137 LabelsAndEventClasses::CHILD_LABEL,
143 LabelsAndEventClasses::EXECUTION_OF_LABEL,
149 LabelsAndEventClasses::PROCESS_ID_LABEL,
156 LabelsAndEventClasses::LAYER,
162 LabelsAndEventClasses::WORKLOAD,
168 LabelsAndEventClasses::NETWORK,
174 LabelsAndEventClasses::CONNECTION,
180 LabelsAndEventClasses::INFERENCE,
186 LabelsAndEventClasses::WORKLOAD_EXECUTION,
192 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS_NAME,
197 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS_NAME_GUID,
203 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS_NAME,
208 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS_NAME_GUID,
213 mockBufferManager.MarkRead(readableBuffer);
216 TEST_CASE(
"CreateNamedTypedChildEntityTest")
220 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
222 arm::pipe::ARMNN_SOFTWARE_INFO,
223 arm::pipe::ARMNN_SOFTWARE_VERSION,
224 arm::pipe::ARMNN_HARDWARE_VERSION);
225 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
226 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
228 ProfilingDynamicGuid childEntityGuid(0);
229 ProfilingGuid parentEntityGuid(123);
230 const std::string entityName =
"some entity";
231 const std::string entityType =
"some type";
234 profilingService.NextGuid();
236 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
"", entityType),
237 arm::pipe::InvalidArgumentException);
238 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, entityName,
""),
239 arm::pipe::InvalidArgumentException);
240 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(
241 childEntityGuid, parentEntityGuid,
"", entityType), arm::pipe::InvalidArgumentException);
242 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(
243 childEntityGuid, parentEntityGuid, entityName,
""), arm::pipe::InvalidArgumentException);
245 CHECK_NOTHROW(childEntityGuid = timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
248 CHECK(childEntityGuid != ProfilingGuid(0));
251 timelineUtilityMethods.Commit();
254 auto readableBuffer = mockBufferManager.GetReadableBuffer();
255 CHECK(readableBuffer !=
nullptr);
256 unsigned int size = readableBuffer->GetSize();
258 const unsigned char* readableData = readableBuffer->GetReadableData();
259 CHECK(readableData !=
nullptr);
262 unsigned int offset = 0;
275 arm::pipe::EmptyOptional(),
276 arm::pipe::EmptyOptional(),
277 arm::pipe::EmptyOptional(),
278 LabelsAndEventClasses::NAME_GUID,
287 arm::pipe::EmptyOptional(),
288 arm::pipe::EmptyOptional(),
289 arm::pipe::EmptyOptional(),
290 LabelsAndEventClasses::TYPE_GUID,
297 arm::pipe::EmptyOptional(),
299 arm::pipe::EmptyOptional(),
300 arm::pipe::EmptyOptional(),
305 mockBufferManager.MarkRead(readableBuffer);
308 TEST_CASE(
"DeclareLabelTest")
312 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
314 arm::pipe::ARMNN_SOFTWARE_INFO,
315 arm::pipe::ARMNN_SOFTWARE_VERSION,
316 arm::pipe::ARMNN_HARDWARE_VERSION);
317 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
318 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
321 profilingService.NextGuid();
324 CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel(
""), arm::pipe::InvalidArgumentException);
327 CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel(
"inv@lid lab€l"), arm::pipe::ProfilingException);
330 const std::string labelName =
"valid label";
331 ProfilingGuid labelGuid = 0;
332 CHECK_NOTHROW(labelGuid = timelineUtilityMethods.DeclareLabel(labelName));
333 CHECK(labelGuid != ProfilingGuid(0));
336 ProfilingGuid newLabelGuid = 0;
337 CHECK_NOTHROW(newLabelGuid = timelineUtilityMethods.DeclareLabel(labelName));
338 CHECK(newLabelGuid != ProfilingGuid(0));
339 CHECK(newLabelGuid == labelGuid);
342 TEST_CASE(
"CreateNameTypeEntityInvalidTest")
346 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
348 arm::pipe::ARMNN_SOFTWARE_INFO,
349 arm::pipe::ARMNN_SOFTWARE_VERSION,
350 arm::pipe::ARMNN_HARDWARE_VERSION);
351 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
352 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
355 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(
"",
"Type"), arm::pipe::InvalidArgumentException);
358 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(
"Name",
""), arm::pipe::InvalidArgumentException);
360 ProfilingDynamicGuid guid = profilingService.NextGuid();
363 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(guid,
"",
"Type"),
364 arm::pipe::InvalidArgumentException);
367 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(guid,
"Name",
""),
368 arm::pipe::InvalidArgumentException);
372 TEST_CASE(
"CreateNameTypeEntityTest")
376 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
378 arm::pipe::ARMNN_SOFTWARE_INFO,
379 arm::pipe::ARMNN_SOFTWARE_VERSION,
380 arm::pipe::ARMNN_HARDWARE_VERSION);
381 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
382 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
384 const std::string entityName =
"Entity0";
385 const std::string entityType =
"Type0";
388 profilingService.NextGuid();
390 ProfilingDynamicGuid guid = timelineUtilityMethods.CreateNamedTypedEntity(entityName, entityType);
391 CHECK(guid != ProfilingGuid(0));
394 timelineUtilityMethods.Commit();
397 auto readableBuffer = mockBufferManager.GetReadableBuffer();
398 CHECK(readableBuffer !=
nullptr);
399 unsigned int size = readableBuffer->GetSize();
401 const unsigned char* readableData = readableBuffer->GetReadableData();
402 CHECK(readableData !=
nullptr);
405 unsigned int offset = 0;
419 arm::pipe::EmptyOptional(),
420 arm::pipe::EmptyOptional(),
421 arm::pipe::EmptyOptional(),
422 LabelsAndEventClasses::NAME_GUID,
432 arm::pipe::EmptyOptional(),
433 arm::pipe::EmptyOptional(),
434 arm::pipe::EmptyOptional(),
435 LabelsAndEventClasses::TYPE_GUID,
441 mockBufferManager.MarkRead(readableBuffer);
444 TEST_CASE(
"RecordEventTest")
448 ProfilingService profilingService(arm::pipe::MAX_ARMNN_COUNTER,
450 arm::pipe::ARMNN_SOFTWARE_INFO,
451 arm::pipe::ARMNN_SOFTWARE_VERSION,
452 arm::pipe::ARMNN_HARDWARE_VERSION);
453 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
454 TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
456 profilingService.NextGuid();
458 ProfilingGuid entityGuid(123);
459 ProfilingStaticGuid eventClassGuid(456);
460 ProfilingDynamicGuid eventGuid(0);
461 CHECK_NOTHROW(eventGuid = timelineUtilityMethods.RecordEvent(entityGuid, eventClassGuid));
462 CHECK(eventGuid != ProfilingGuid(0));
465 timelineUtilityMethods.Commit();
468 auto readableBuffer = mockBufferManager.GetReadableBuffer();
469 CHECK(readableBuffer !=
nullptr);
470 unsigned int size = readableBuffer->GetSize();
472 CHECK(size == 68 + ThreadIdSize);
474 const unsigned char* readableData = readableBuffer->GetReadableData();
475 CHECK(readableData !=
nullptr);
478 unsigned int offset = 0;
485 arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), arm::pipe::EmptyOptional(), readableData, offset);
489 arm::pipe::EmptyOptional(),
497 mockBufferManager.MarkRead(readableBuffer);
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineEntityBinaryPacketData(arm::pipe::Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, arm::pipe::Optional< ProfilingGuid > relationshipGuid, arm::pipe::Optional< ProfilingGuid > headGuid, arm::pipe::Optional< ProfilingGuid > tailGuid, arm::pipe::Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineLabelBinaryPacketData(arm::pipe::Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)
void VerifyTimelineHeaderBinary(const unsigned char *readableData, unsigned int &offset, uint32_t packetDataLength)
ProfilingGuid VerifyTimelineEventBinaryPacket(arm::pipe::Optional< uint64_t > timestamp, arm::pipe::Optional< int > threadId, arm::pipe::Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)