13 #include <common/include/LabelsAndEventClasses.hpp> 17 #include <doctest/doctest.h> 19 using namespace armnn;
24 TEST_CASE(
"CreateTypedLabelTest")
29 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
35 ProfilingGuid entityGuid(123);
36 const std::string entityName =
"some entity";
37 ProfilingStaticGuid labelTypeGuid(456);
39 CHECK_NOTHROW(timelineUtilityMethods.MarkEntityWithLabel(entityGuid, entityName, labelTypeGuid));
42 timelineUtilityMethods.Commit();
46 CHECK(readableBuffer !=
nullptr);
47 unsigned int size = readableBuffer->GetSize();
49 const unsigned char* readableData = readableBuffer->GetReadableData();
50 CHECK(readableData !=
nullptr);
53 unsigned int offset = 0;
71 mockBufferManager.
MarkRead(readableBuffer);
74 TEST_CASE(
"SendWellKnownLabelsAndEventClassesTest")
84 CHECK(readableBuffer !=
nullptr);
85 unsigned int size = readableBuffer->GetSize();
87 const unsigned char* readableData = readableBuffer->GetReadableData();
88 CHECK(readableData !=
nullptr);
91 unsigned int offset = 0;
98 LabelsAndEventClasses::NAME_LABEL,
104 LabelsAndEventClasses::TYPE_LABEL,
110 LabelsAndEventClasses::INDEX_LABEL,
116 LabelsAndEventClasses::BACKENDID_LABEL,
122 LabelsAndEventClasses::CHILD_LABEL,
128 LabelsAndEventClasses::EXECUTION_OF_LABEL,
134 LabelsAndEventClasses::PROCESS_ID_LABEL,
141 LabelsAndEventClasses::LAYER,
147 LabelsAndEventClasses::WORKLOAD,
153 LabelsAndEventClasses::NETWORK,
159 LabelsAndEventClasses::CONNECTION,
165 LabelsAndEventClasses::INFERENCE,
171 LabelsAndEventClasses::WORKLOAD_EXECUTION,
177 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS_NAME,
182 LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS_NAME_GUID,
188 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS_NAME,
193 LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS_NAME_GUID,
198 mockBufferManager.
MarkRead(readableBuffer);
201 TEST_CASE(
"CreateNamedTypedChildEntityTest")
205 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
208 ProfilingDynamicGuid childEntityGuid(0);
209 ProfilingGuid parentEntityGuid(123);
210 const std::string entityName =
"some entity";
211 const std::string entityType =
"some type";
216 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
"", entityType),
218 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, entityName,
""),
220 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(
222 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedChildEntity(
225 CHECK_NOTHROW(childEntityGuid = timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
228 CHECK(childEntityGuid != ProfilingGuid(0));
231 timelineUtilityMethods.Commit();
235 CHECK(readableBuffer !=
nullptr);
236 unsigned int size = readableBuffer->GetSize();
238 const unsigned char* readableData = readableBuffer->GetReadableData();
239 CHECK(readableData !=
nullptr);
242 unsigned int offset = 0;
258 LabelsAndEventClasses::NAME_GUID,
270 LabelsAndEventClasses::TYPE_GUID,
285 mockBufferManager.
MarkRead(readableBuffer);
288 TEST_CASE(
"DeclareLabelTest")
292 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
302 CHECK_THROWS_AS(timelineUtilityMethods.DeclareLabel(
"inv@lid lab€l"),
RuntimeException);
305 const std::string labelName =
"valid label";
306 ProfilingGuid labelGuid = 0;
307 CHECK_NOTHROW(labelGuid = timelineUtilityMethods.DeclareLabel(labelName));
308 CHECK(labelGuid != ProfilingGuid(0));
311 ProfilingGuid newLabelGuid = 0;
312 CHECK_NOTHROW(newLabelGuid = timelineUtilityMethods.DeclareLabel(labelName));
313 CHECK(newLabelGuid != ProfilingGuid(0));
314 CHECK(newLabelGuid == labelGuid);
317 TEST_CASE(
"CreateNameTypeEntityInvalidTest")
321 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
330 ProfilingDynamicGuid guid = profilingService.
NextGuid();
333 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(guid,
"",
"Type"),
337 CHECK_THROWS_AS(timelineUtilityMethods.CreateNamedTypedEntity(guid,
"Name",
""),
342 TEST_CASE(
"CreateNameTypeEntityTest")
346 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
349 const std::string entityName =
"Entity0";
350 const std::string entityType =
"Type0";
355 ProfilingDynamicGuid guid = timelineUtilityMethods.CreateNamedTypedEntity(entityName, entityType);
356 CHECK(guid != ProfilingGuid(0));
359 timelineUtilityMethods.Commit();
363 CHECK(readableBuffer !=
nullptr);
364 unsigned int size = readableBuffer->GetSize();
366 const unsigned char* readableData = readableBuffer->GetReadableData();
367 CHECK(readableData !=
nullptr);
370 unsigned int offset = 0;
387 LabelsAndEventClasses::NAME_GUID,
400 LabelsAndEventClasses::TYPE_GUID,
406 mockBufferManager.
MarkRead(readableBuffer);
409 TEST_CASE(
"RecordEventTest")
413 std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = std::make_unique<SendTimelinePacket>(mockBufferManager);
418 ProfilingGuid entityGuid(123);
419 ProfilingStaticGuid eventClassGuid(456);
420 ProfilingDynamicGuid eventGuid(0);
421 CHECK_NOTHROW(eventGuid = timelineUtilityMethods.RecordEvent(entityGuid, eventClassGuid));
422 CHECK(eventGuid != ProfilingGuid(0));
425 timelineUtilityMethods.Commit();
429 CHECK(readableBuffer !=
nullptr);
430 unsigned int size = readableBuffer->GetSize();
434 const unsigned char* readableData = readableBuffer->GetReadableData();
435 CHECK(readableData !=
nullptr);
438 unsigned int offset = 0;
456 mockBufferManager.
MarkRead(readableBuffer);
TEST_SUITE("TestConstTensorLayerVisitor")
void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, ProfilingGuid nameGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineEntityBinaryPacketData(Optional< ProfilingGuid > guid, const unsigned char *readableData, unsigned int &offset)
Head retains(parents) Tail.
Copyright (c) 2021 ARM Limited and Contributors.
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
void MarkRead(IPacketBufferPtr &packetBuffer) override
void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional< ProfilingGuid > relationshipGuid, Optional< ProfilingGuid > headGuid, Optional< ProfilingGuid > tailGuid, Optional< ProfilingGuid > attributeGuid, const unsigned char *readableData, unsigned int &offset)
IPacketBufferPtr GetReadableBuffer() override
constexpr unsigned int ThreadIdSize
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...
static void SendWellKnownLabelsAndEventClasses(ISendTimelinePacket &timelinePacket)
ProfilingGuid VerifyTimelineEventBinaryPacket(Optional< uint64_t > timestamp, Optional< int > threadId, Optional< ProfilingGuid > eventGuid, const unsigned char *readableData, unsigned int &offset)
ProfilingGuid VerifyTimelineLabelBinaryPacketData(Optional< ProfilingGuid > guid, const std::string &label, const unsigned char *readableData, unsigned int &offset)