surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #ifdef ARMNN_HEAP_PROFILING_ENABLED |
| 8 | |
| 9 | #include <string> |
| 10 | #include <cstddef> |
| 11 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 12 | // This is conditional so we can change the environment variable |
| 13 | // at build time. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 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: |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 27 | // Location comes from the ARMNN_HEAP_PROFILE_DUMP_DIR. |
| 28 | // If it is not available then it dumps to /tmp. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 29 | std::string m_Location; |
| 30 | std::string m_Tag; |
| 31 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 32 | // No default construction and copying. |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 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 |