diff options
author | Finn Williams <Finn.Williams@arm.com> | 2019-10-15 14:22:13 +0100 |
---|---|---|
committer | Jim Flynn Arm <jim.flynn@arm.com> | 2019-10-21 16:52:03 +0000 |
commit | 15db745d59a796fd05e3bb5a8b735f25710bdf22 (patch) | |
tree | 01e5e320bd92cb152464adb82c02e3b37342b571 /tests/profiling/gatordmock/MockUtils.cpp | |
parent | 422f2fb6c7ef13e48124991af6f27e78934b8ece (diff) | |
download | armnn-15db745d59a796fd05e3bb5a8b735f25710bdf22.tar.gz |
IVGCVSW-3989 Create the Counter Directory Decoder
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: If388e60434eae39d82b639d2275680679963624c
Diffstat (limited to 'tests/profiling/gatordmock/MockUtils.cpp')
-rw-r--r-- | tests/profiling/gatordmock/MockUtils.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/profiling/gatordmock/MockUtils.cpp b/tests/profiling/gatordmock/MockUtils.cpp new file mode 100644 index 0000000000..bdbffc9253 --- /dev/null +++ b/tests/profiling/gatordmock/MockUtils.cpp @@ -0,0 +1,57 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "MockUtils.hpp" + +namespace armnn +{ + +namespace gatordmock +{ + +std::string CentreAlignFormatting(const std::string& stringToPass, const int spacingWidth) +{ + std::stringstream outputStream, centrePadding; + int padding = spacingWidth - static_cast<int>(stringToPass.size()); + + for (int i = 0; i < padding / 2; ++i) + { + centrePadding << " "; + } + + outputStream << centrePadding.str() << stringToPass << centrePadding.str(); + + if (padding > 0 && padding %2 != 0) + { + outputStream << " "; + } + + return outputStream.str(); +} + +std::string GetStringNameFromBuffer(const unsigned char* const data, uint32_t offset) +{ + std::string deviceName; + u_char nextChar = profiling::ReadUint8(data, offset); + + while (IsValidChar(nextChar)) + { + deviceName += static_cast<char>(nextChar); + offset ++; + nextChar = profiling::ReadUint8(data, offset); + } + + return deviceName; +} + +bool IsValidChar(unsigned char c) +{ + // Check that the given character has ASCII 7-bit encoding, alpha-numeric, whitespace, and underscore only + return c < 128 && (std::isalnum(c) || c == '_' || c == ' '); +} + +} // gatordmock + +} // armnn |