blob: 0444531d02b01055c442eafdb94119335604a44d (
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
|
#pragma once
#include <Common/ProfileEvents.h>
#include <Common/CurrentThread.h>
namespace DB
{
/// Use specific performance counters for current thread in the current scope.
class ProfileEventsScope : private boost::noncopyable
{
public:
/// Counters are owned by this object.
ProfileEventsScope();
/// Shared counters are stored outside.
/// Useful when we calculate metrics entering into some scope several times.
explicit ProfileEventsScope(ProfileEvents::Counters * performance_counters_scope_);
std::shared_ptr<ProfileEvents::Counters::Snapshot> getSnapshot();
~ProfileEventsScope();
private:
/// If set, then performance_counters_scope is owned by this object.
/// Otherwise, counters are passed to the constructor from outside.
std::unique_ptr<ProfileEvents::Counters> performance_counters_holder;
ProfileEvents::Counters * performance_counters_scope;
ProfileEvents::Counters * previous_counters_scope;
};
}
|