diff options
Diffstat (limited to 'tests/profiling')
3 files changed, 54 insertions, 27 deletions
diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp index cb860a950b..f28c7b50bf 100644 --- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp +++ b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp @@ -5,9 +5,13 @@ #include "TimelineDirectoryCaptureCommandHandler.hpp" +#include <ProfilingUtils.hpp> + #include <iostream> #include <string> +using namespace armnn::profiling; + namespace armnn { @@ -25,10 +29,17 @@ void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::P const unsigned char* data = packet.GetData(); + m_SwTraceHeader.m_StreamVersion = ReadUint8(data, offset); + offset += uint8_t_size; + m_SwTraceHeader.m_PointerBytes = ReadUint8(data, offset); + offset += uint8_t_size; + m_SwTraceHeader.m_ThreadIdBytes = ReadUint8(data, offset); + offset += uint8_t_size; + uint32_t numberOfDeclarations = profiling::ReadUint32(data, offset); offset += uint32_t_size; - for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration) + for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration) { m_SwTraceMessages.push_back(profiling::ReadSwTraceMessage(data, offset)); } @@ -54,21 +65,21 @@ void TimelineDirectoryCaptureCommandHandler::Print() std::cout << "\n"; std::cout << std::string(header.size(), '=') << "\n"; - std::cout<< header; + std::cout << header; - for (auto swTraceMessage : m_SwTraceMessages) + for (const auto& swTraceMessage : m_SwTraceMessages) { std::string body; - body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.id), 12)); + body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.m_Id), 12)); body.append(" | "); - body.append(profiling::CentreAlignFormatting(swTraceMessage.name, 20)); + body.append(profiling::CentreAlignFormatting(swTraceMessage.m_Name, 20)); body.append(" | "); - body.append(profiling::CentreAlignFormatting(swTraceMessage.uiName, 20)); + body.append(profiling::CentreAlignFormatting(swTraceMessage.m_UiName, 20)); body.append(" | "); std::string argTypes; - for(auto argType: swTraceMessage.argTypes) + for (auto argType: swTraceMessage.m_ArgTypes) { argTypes += argType; argTypes += " "; @@ -77,7 +88,7 @@ void TimelineDirectoryCaptureCommandHandler::Print() body.append(" | "); std::string argNames; - for(auto argName: swTraceMessage.argNames) + for (auto argName: swTraceMessage.m_ArgNames) { argNames += argName + " "; } @@ -87,7 +98,7 @@ void TimelineDirectoryCaptureCommandHandler::Print() std::cout << std::string(body.size(), '-') << "\n"; - std::cout<< body; + std::cout << body; } } @@ -95,7 +106,7 @@ void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& { ParseData(packet); - if(!m_QuietOperation) + if (!m_QuietOperation) { Print(); } @@ -103,4 +114,4 @@ void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& } //namespace gatordmock -} //namespace armnn
\ No newline at end of file +} //namespace armnn diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp index 3a575d7fef..36a82b5510 100644 --- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp +++ b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp @@ -20,6 +20,7 @@ namespace gatordmock class TimelineDirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor { // Utils + uint32_t uint8_t_size = sizeof(uint8_t); uint32_t uint32_t_size = sizeof(uint32_t); public: @@ -27,12 +28,13 @@ public: uint32_t packetId, uint32_t version, bool quietOperation = false) - : CommandHandlerFunctor(familyId, packetId, version) - , m_QuietOperation(quietOperation) + : CommandHandlerFunctor(familyId, packetId, version) + , m_QuietOperation(quietOperation) {} void operator()(const armnn::profiling::Packet& packet) override; + profiling::SwTraceHeader m_SwTraceHeader; std::vector<profiling::SwTraceMessage> m_SwTraceMessages; private: @@ -44,4 +46,4 @@ private: } //namespace gatordmock -} //namespace armnn
\ No newline at end of file +} //namespace armnn diff --git a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp b/tests/profiling/timelineDecoder/tests/TimelineTests.cpp index a9c352b5fa..8106e6a996 100644 --- a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp +++ b/tests/profiling/timelineDecoder/tests/TimelineTests.cpp @@ -35,18 +35,22 @@ void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer, uint32_t PacketDataLength = header[1] & 0x00FFFFFF; - std::unique_ptr<unsigned char[]> uniquePacketData = std::make_unique<unsigned char[]>(PacketDataLength); - + auto uniquePacketData = std::make_unique<unsigned char[]>(PacketDataLength); std::memcpy(uniquePacketData.get(), packetBuffer + offset, PacketDataLength); - armnn::profiling::Packet packet = armnn::profiling::Packet(header[0], PacketDataLength, uniquePacketData); + armnn::profiling::Packet packet(header[0], PacketDataLength, uniquePacketData); + + BOOST_CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0); CommandHandler(packet); } -BOOST_AUTO_TEST_CASE(TimelineDirecotryTest) +BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) { + uint32_t uint8_t_size = sizeof(uint8_t); uint32_t uint32_t_size = sizeof(uint32_t); + uint32_t uint64_t_size = sizeof(uint64_t); + uint32_t threadId_size = sizeof(std::thread::id); profiling::BufferManager bufferManager(5); profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -68,6 +72,16 @@ BOOST_AUTO_TEST_CASE(TimelineDirecotryTest) std::unique_ptr<profiling::IPacketBuffer> packetBuffer = bufferManager.GetReadableBuffer(); + uint8_t readStreamVersion = ReadUint8(packetBuffer, offset); + BOOST_CHECK(readStreamVersion == 4); + offset += uint8_t_size; + uint8_t readPointerBytes = ReadUint8(packetBuffer, offset); + BOOST_CHECK(readPointerBytes == uint64_t_size); + offset += uint8_t_size; + uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset); + BOOST_CHECK(readThreadIdBytes == threadId_size); + offset += uint8_t_size; + uint32_t declarationSize = profiling::ReadUint32(packetBuffer, offset); offset += uint32_t_size; for(uint32_t i = 0; i < declarationSize; ++i) @@ -82,20 +96,20 @@ BOOST_AUTO_TEST_CASE(TimelineDirecotryTest) profiling::SwTraceMessage& bufferMessage = swTraceBufferMessages[index]; profiling::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index]; - BOOST_CHECK(bufferMessage.name == handlerMessage.name); - BOOST_CHECK(bufferMessage.uiName == handlerMessage.uiName); - BOOST_CHECK(bufferMessage.id == handlerMessage.id); + BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name); + BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName); + BOOST_CHECK(bufferMessage.m_Id == handlerMessage.m_Id); - BOOST_CHECK(bufferMessage.argTypes.size() == handlerMessage.argTypes.size()); - for(uint32_t i = 0; i < bufferMessage.argTypes.size(); ++i) + BOOST_CHECK(bufferMessage.m_ArgTypes.size() == handlerMessage.m_ArgTypes.size()); + for(uint32_t i = 0; i < bufferMessage.m_ArgTypes.size(); ++i) { - BOOST_CHECK(bufferMessage.argTypes[i] == handlerMessage.argTypes[i]); + BOOST_CHECK(bufferMessage.m_ArgTypes[i] == handlerMessage.m_ArgTypes[i]); } - BOOST_CHECK(bufferMessage.argNames.size() == handlerMessage.argNames.size()); - for(uint32_t i = 0; i < bufferMessage.argNames.size(); ++i) + BOOST_CHECK(bufferMessage.m_ArgNames.size() == handlerMessage.m_ArgNames.size()); + for(uint32_t i = 0; i < bufferMessage.m_ArgNames.size(); ++i) { - BOOST_CHECK(bufferMessage.argNames[i] == handlerMessage.argNames[i]); + BOOST_CHECK(bufferMessage.m_ArgNames[i] == handlerMessage.m_ArgNames[i]); } } } |