blob: febcbfe2b30d2922938c43bb9b7dd94810feb67d [file] [log] [blame]
surmeh013537c2c2018-05-18 16:31:43 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// See LICENSE file in the project root for full license information.
4//
5#pragma once
6
7#ifdef ARMNN_HEAP_PROFILING_ENABLED
8
9#include <string>
10#include <cstddef>
11
12// this is conditional so we can change the environment variable
13// at build time
14#ifndef ARMNN_HEAP_PROFILE_DUMP_DIR
15#define ARMNN_HEAP_PROFILE_DUMP_DIR "ARMNN_HEAP_PROFILE_DUMP_DIR"
16#endif // ARMNN_HEAP_PROFILE_DUMP_DIR
17
18namespace armnnUtils
19{
20class ScopedHeapProfiler final
21{
22public:
23 ScopedHeapProfiler(const std::string & tag);
24 ~ScopedHeapProfiler();
25
26private:
27 // Location comes from the ARMNN_HEAP_PROFILE_DUMP_DIR
28 // if not available then it dumps to /tmp
29 std::string m_Location;
30 std::string m_Tag;
31
32 // No default construction and copying
33 ScopedHeapProfiler() = delete;
34 ScopedHeapProfiler(const ScopedHeapProfiler &) = delete;
35 ScopedHeapProfiler & operator=(const ScopedHeapProfiler &) = delete;
36};
37
38} // namespace armnnUtils
39
40#define ARMNN_SCOPED_HEAP_PROFILING(TAG) \
41 armnnUtils::ScopedHeapProfiler __scoped_armnn_heap_profiler__(TAG)
42
43#else // ARMNN_HEAP_PROFILING_ENABLED
44
45#define ARMNN_SCOPED_HEAP_PROFILING(TAG)
46
47#endif // ARMNN_HEAP_PROFILING_ENABLED