blob: 54177b81757fd3e1730e545a31e94f1fd9d5052a [file] [log] [blame]
surmeh013537c2c2018-05-18 16:31:43 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
surmeh013537c2c2018-05-18 16:31:43 +01004//
5#pragma once
6
7#ifdef ARMNN_HEAP_PROFILING_ENABLED
8
9#include <string>
10#include <cstddef>
11
telsoa01c577f2c2018-08-31 09:22:23 +010012// This is conditional so we can change the environment variable
13// at build time.
surmeh013537c2c2018-05-18 16:31:43 +010014#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:
telsoa01c577f2c2018-08-31 09:22:23 +010027 // Location comes from the ARMNN_HEAP_PROFILE_DUMP_DIR.
28 // If it is not available then it dumps to /tmp.
surmeh013537c2c2018-05-18 16:31:43 +010029 std::string m_Location;
30 std::string m_Tag;
31
telsoa01c577f2c2018-08-31 09:22:23 +010032 // No default construction and copying.
surmeh013537c2c2018-05-18 16:31:43 +010033 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