aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-11-19 15:49:18 +0000
committerJim Flynn Arm <jim.flynn@arm.com>2019-11-19 17:59:54 +0000
commit234d525ac7dbfb3dc387a5555ce7ac0023f97ebe (patch)
tree933dbf2192395918161090ce878f6f8a10d683a9
parent434de54b07791b797b20eac34b591f8b3e5df466 (diff)
downloadarmnn-234d525ac7dbfb3dc387a5555ce7ac0023f97ebe.tar.gz
IVGCVSW-4070 Add CreatedNamedTypeEntity and CreateNamedTypedChildEntity
functions with Guid Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: Ide3c3b0a05830af055b3a2c733af4c1c57c0dbaa
-rw-r--r--src/profiling/TimelineUtilityMethods.cpp55
-rw-r--r--src/profiling/TimelineUtilityMethods.hpp7
-rw-r--r--src/profiling/test/TimelineUtilityMethodsTests.cpp16
3 files changed, 75 insertions, 3 deletions
diff --git a/src/profiling/TimelineUtilityMethods.cpp b/src/profiling/TimelineUtilityMethods.cpp
index 8c84aa73e9..c1ae610e49 100644
--- a/src/profiling/TimelineUtilityMethods.cpp
+++ b/src/profiling/TimelineUtilityMethods.cpp
@@ -51,6 +51,27 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::s
// Generate dynamic GUID of the entity
ProfilingDynamicGuid entityGuid = ProfilingService::Instance().NextGuid();
+ CreateNamedTypedEntity(entityGuid, name, type);
+
+ return entityGuid;
+}
+
+void TimelineUtilityMethods::CreateNamedTypedEntity(ProfilingDynamicGuid entityGuid,
+ const std::string& name,
+ const std::string& type)
+{
+ // Check that the entity name is valid
+ if (name.empty())
+ {
+ throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty");
+ }
+
+ // Check that the entity type is valid
+ if (type.empty())
+ {
+ throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty");
+ }
+
// Send Entity Binary Packet of the entity to the external profiling service
m_SendTimelinePacket.SendTimelineEntityBinaryPacket(entityGuid);
@@ -59,8 +80,6 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedEntity(const std::s
// Create type entity and send the relationship of the entity with the given type
TypeEntity(entityGuid, type);
-
- return entityGuid;
}
ProfilingStaticGuid TimelineUtilityMethods::DeclareLabel(const std::string& labelName)
@@ -157,6 +176,38 @@ ProfilingDynamicGuid TimelineUtilityMethods::CreateNamedTypedChildEntity(Profili
return childEntityGuid;
}
+void TimelineUtilityMethods::CreateNamedTypedChildEntity(ProfilingDynamicGuid childEntityGuid,
+ ProfilingGuid parentEntityGuid,
+ const std::string& entityName,
+ const std::string& entityType)
+{
+ // Check that the entity name is valid
+ if (entityName.empty())
+ {
+ // The entity name is invalid
+ throw InvalidArgumentException("Invalid entity name, the entity name cannot be empty");
+ }
+
+ // Check that the entity type is valid
+ if (entityType.empty())
+ {
+ // The entity type is invalid
+ throw InvalidArgumentException("Invalid entity type, the entity type cannot be empty");
+ }
+
+ // Create a named type entity from the given guid, name and type, this call throws in case of error
+ CreateNamedTypedEntity(childEntityGuid, entityName, entityType);
+
+ // Generate a GUID for the retention link relationship
+ ProfilingDynamicGuid retentionLinkGuid = ProfilingService::Instance().NextGuid();
+
+ // Send the new retention link to the external profiling service, this call throws in case of error
+ m_SendTimelinePacket.SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink,
+ retentionLinkGuid,
+ parentEntityGuid,
+ childEntityGuid);
+}
+
ProfilingDynamicGuid TimelineUtilityMethods::RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid)
{
// Take a timestamp
diff --git a/src/profiling/TimelineUtilityMethods.hpp b/src/profiling/TimelineUtilityMethods.hpp
index 51fceb95f4..3683ed3383 100644
--- a/src/profiling/TimelineUtilityMethods.hpp
+++ b/src/profiling/TimelineUtilityMethods.hpp
@@ -26,6 +26,8 @@ public:
ProfilingDynamicGuid CreateNamedTypedEntity(const std::string& name, const std::string& type);
+ void CreateNamedTypedEntity(ProfilingDynamicGuid entityGuid, const std::string& name, const std::string& type);
+
void CreateTypedLabel(ProfilingGuid entityGuid, const std::string& entityName, ProfilingStaticGuid labelTypeGuid);
ProfilingStaticGuid DeclareLabel(const std::string& labelName);
@@ -38,6 +40,11 @@ public:
const std::string& entityName,
const std::string& entityType);
+ void CreateNamedTypedChildEntity(ProfilingDynamicGuid entityGuid,
+ ProfilingGuid parentEntityGuid,
+ const std::string& entityName,
+ const std::string& entityType);
+
ProfilingDynamicGuid RecordEvent(ProfilingGuid entityGuid, ProfilingStaticGuid eventClassGuid);
private:
diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp
index 2eb96e62d1..7d1a7c1a87 100644
--- a/src/profiling/test/TimelineUtilityMethodsTests.cpp
+++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp
@@ -474,6 +474,7 @@ BOOST_AUTO_TEST_CASE(CreateNamedTypedChildEntityTest)
SendTimelinePacket sendTimelinePacket(mockBufferManager);
TimelineUtilityMethods timelineUtilityMethods(sendTimelinePacket);
+ ProfilingDynamicGuid childEntityGuid(0);
ProfilingGuid parentEntityGuid(123);
const std::string entityName = "some entity";
const std::string entityType = "some type";
@@ -485,8 +486,11 @@ BOOST_AUTO_TEST_CASE(CreateNamedTypedChildEntityTest)
InvalidArgumentException);
BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid, entityName, ""),
InvalidArgumentException);
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(
+ childEntityGuid, parentEntityGuid, "", entityType), InvalidArgumentException);
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedChildEntity(
+ childEntityGuid, parentEntityGuid, entityName, ""), InvalidArgumentException);
- ProfilingGuid childEntityGuid(0);
BOOST_CHECK_NO_THROW(childEntityGuid = timelineUtilityMethods.CreateNamedTypedChildEntity(parentEntityGuid,
entityName,
entityType));
@@ -599,6 +603,16 @@ BOOST_AUTO_TEST_CASE(CreateNameTypeEntityInvalidTest)
// Invalid type
BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity("Name", ""), InvalidArgumentException);
+ ProfilingDynamicGuid guid = ProfilingService::Instance().NextGuid();
+
+ // CreatedNamedTypedEntity with Guid - Invalid name
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity(guid, "", "Type"),
+ InvalidArgumentException);
+
+ // CreatedNamedTypedEntity with Guid - Invalid type
+ BOOST_CHECK_THROW(timelineUtilityMethods.CreateNamedTypedEntity(guid, "Name", ""),
+ InvalidArgumentException);
+
}
BOOST_AUTO_TEST_CASE(CreateNameTypeEntityTest)