diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-10-22 10:30:49 +0100 |
---|---|---|
committer | David Monahan <david.monahan@arm.com> | 2019-11-07 12:20:47 +0000 |
commit | e63a026bd987e78bdaa5b94c3e53201b62011faa (patch) | |
tree | cad6e7dcc7107b723ecc92116a96eda80100a99e /tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp | |
parent | 362e03214ceceb95ec30d530ff84e8d9efc198d7 (diff) | |
download | armnn-e63a026bd987e78bdaa5b94c3e53201b62011faa.tar.gz |
IVGCVSW-3951 Create the timeline decoder
* Added ITimelineDecoder.h C interface
* Added an example implementation of ITimelineDecoder.h
* Added command handlers for the timeline directory and objects
* Added tests for the decoder implementation
* Changed ReadSwTraceMessage to take a const unsigned char*
so it can be used by the directory command handler
* Fixed some bugs in ProfilingUtils.cpp and related tests
Change-Id: If06faf1fe0274a8f022f194a6d3527f5ce5374c6
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Diffstat (limited to 'tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp')
-rw-r--r-- | tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp new file mode 100644 index 0000000000..cb860a950b --- /dev/null +++ b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp @@ -0,0 +1,106 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "TimelineDirectoryCaptureCommandHandler.hpp" + +#include <iostream> +#include <string> + +namespace armnn +{ + +namespace gatordmock +{ + +void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet) +{ + uint32_t offset = 0; + + if (packet.GetLength() < 8) + { + return; + } + + const unsigned char* data = packet.GetData(); + + uint32_t numberOfDeclarations = profiling::ReadUint32(data, offset); + offset += uint32_t_size; + + for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration) + { + m_SwTraceMessages.push_back(profiling::ReadSwTraceMessage(data, offset)); + } +} + +void TimelineDirectoryCaptureCommandHandler::Print() +{ + std::string header; + + header.append(profiling::CentreAlignFormatting("decl_id", 12)); + header.append(" | "); + header.append(profiling::CentreAlignFormatting("decl_name", 20)); + header.append(" | "); + header.append(profiling::CentreAlignFormatting("ui_name", 20)); + header.append(" | "); + header.append(profiling::CentreAlignFormatting("arg_types", 16)); + header.append(" | "); + header.append(profiling::CentreAlignFormatting("arg_names", 80)); + header.append("\n"); + + std::cout << "\n" << "\n"; + std::cout << profiling::CentreAlignFormatting("SW DIRECTORY", static_cast<int>(header.size())); + std::cout << "\n"; + std::cout << std::string(header.size(), '=') << "\n"; + + std::cout<< header; + + for (auto swTraceMessage : m_SwTraceMessages) + { + std::string body; + + body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.id), 12)); + body.append(" | "); + body.append(profiling::CentreAlignFormatting(swTraceMessage.name, 20)); + body.append(" | "); + body.append(profiling::CentreAlignFormatting(swTraceMessage.uiName, 20)); + body.append(" | "); + + std::string argTypes; + for(auto argType: swTraceMessage.argTypes) + { + argTypes += argType; + argTypes += " "; + } + body.append(profiling::CentreAlignFormatting(argTypes, 16)); + body.append(" | "); + + std::string argNames; + for(auto argName: swTraceMessage.argNames) + { + argNames += argName + " "; + } + body.append(profiling::CentreAlignFormatting(argNames, 80)); + + body.append("\n"); + + std::cout << std::string(body.size(), '-') << "\n"; + + std::cout<< body; + } +} + +void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet) +{ + ParseData(packet); + + if(!m_QuietOperation) + { + Print(); + } +} + +} //namespace gatordmock + +} //namespace armnn
\ No newline at end of file |