Coverage Report

Created: 2024-11-21 12:22

/root/doris/be/src/runtime/process_profile.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <common/multi_version.h>
21
22
#include "runtime/exec_env.h"
23
#include "runtime/memory/memory_profile.h"
24
#include "util/runtime_profile.h"
25
26
namespace doris {
27
28
class ProcessProfile {
29
public:
30
1
    static ProcessProfile* create_global_instance() { return new ProcessProfile(); }
31
0
    static ProcessProfile* instance() { return ExecEnv::GetInstance()->get_process_profile(); }
32
    ProcessProfile();
33
34
    void refresh_profile();
35
36
0
    std::string print_process_profile() const {
37
0
        auto version_ptr = _process_profile.get();
38
0
        std::stringstream ss;
39
0
        version_ptr->pretty_print(&ss);
40
0
        return ss.str();
41
0
    }
42
43
0
    std::string print_process_profile_no_root() const {
44
0
        std::stringstream ss;
45
0
        std::vector<RuntimeProfile*> profiles;
46
0
        auto version_ptr = _process_profile.get();
47
0
        auto* process_profile = const_cast<doris::RuntimeProfile*>(version_ptr.get());
48
0
        process_profile->get_children(&profiles);
49
0
        for (auto* profile : profiles) {
50
0
            profile->pretty_print(&ss);
51
0
        }
52
0
        return ss.str();
53
0
    }
54
55
0
    MemoryProfile* memory_profile() { return _memory_profile.get(); }
56
57
private:
58
    MultiVersion<RuntimeProfile> _process_profile;
59
    std::unique_ptr<MemoryProfile> _memory_profile;
60
};
61
62
} // namespace doris