ArmNN
 24.08
HeapProfiling.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
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 
18 namespace armnnUtils
19 {
20 class ScopedHeapProfiler final
21 {
22 public:
23  ScopedHeapProfiler(const std::string & tag);
24  ~ScopedHeapProfiler();
25 
26 private:
27  // Location comes from the ARMNN_HEAP_PROFILE_DUMP_DIR.
28  // If it is 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
armnnUtils
Definition: CompatibleTypes.hpp:10