diff options
author | surmeh01 <surabhi.mehta@arm.com> | 2018-05-18 16:31:43 +0100 |
---|---|---|
committer | telsoa01 <telmo.soares@arm.com> | 2018-05-23 13:09:07 +0100 |
commit | 3537c2ca7ebf31c1673b9ec2bb0c17b0406bbae0 (patch) | |
tree | 5950603ad78ec3fe56fb31ddc7f4d52a19f5bc60 /src/armnnUtils/HeapProfiling.cpp | |
parent | bceff2fb3fc68bb0aa88b886900c34b77340c826 (diff) | |
download | armnn-3537c2ca7ebf31c1673b9ec2bb0c17b0406bbae0.tar.gz |
Release 18.05
Diffstat (limited to 'src/armnnUtils/HeapProfiling.cpp')
-rw-r--r-- | src/armnnUtils/HeapProfiling.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/armnnUtils/HeapProfiling.cpp b/src/armnnUtils/HeapProfiling.cpp new file mode 100644 index 0000000000..7f99927511 --- /dev/null +++ b/src/armnnUtils/HeapProfiling.cpp @@ -0,0 +1,38 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#ifdef ARMNN_HEAP_PROFILING_ENABLED + +#include "HeapProfiling.hpp" +#include "gperftools/heap-profiler.h" +#include <sstream> +#include <cstdlib> + +namespace armnnUtils +{ + +ScopedHeapProfiler::ScopedHeapProfiler(const std::string & tag) +: m_Location("/tmp") +, m_Tag(tag) +{ + char * locationFromEnv = ::getenv(ARMNN_HEAP_PROFILE_DUMP_DIR); + if (locationFromEnv) + { + m_Location = locationFromEnv; + } + std::stringstream ss; + ss << m_Location << "/" << m_Tag << ".hprof"; + HeapProfilerStart(ss.str().c_str()); + HeapProfilerDump(m_Tag.c_str()); +} + +ScopedHeapProfiler::~ScopedHeapProfiler() +{ + HeapProfilerDump(m_Tag.c_str()); +} + +} // namespace armnnUtils + +#endif // ARMNN_HEAP_PROFILING_ENABLED |