blob: c07a6c0be606060578602a6c6c45352c6d8c02b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#pragma once
#include "stackcollect.h"
#include <library/cpp/lfalloc/dbg_info/dbg_info.h>
#include <util/generic/noncopyable.h>
#include <util/stream/output.h>
namespace NAllocProfiler {
////////////////////////////////////////////////////////////////////////////////
inline int SetCurrentScopeTag(int value)
{
return NAllocDbg::SetThreadAllocTag(value);
}
inline bool SetProfileCurrentThread(bool value)
{
return NAllocDbg::SetProfileCurrentThread(value);
}
bool StartAllocationSampling(bool profileAllThreads = false);
bool StopAllocationSampling(IAllocationStatsDumper& out, int count = 100);
bool StopAllocationSampling(IOutputStream& out, int count = 100);
////////////////////////////////////////////////////////////////////////////////
class TProfilingScope: private TNonCopyable {
private:
const int Prev;
public:
explicit TProfilingScope(int value)
: Prev(SetCurrentScopeTag(value))
{}
~TProfilingScope()
{
SetCurrentScopeTag(Prev);
}
};
} // namespace NAllocProfiler
|