• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_RUNTIME_DPROFILER_DPROFILER_H_
17 #define PANDA_RUNTIME_DPROFILER_DPROFILER_H_
18 
19 #include <memory>
20 #include <string>
21 #include <unordered_set>
22 
23 #include "dprof/profiling_data.h"
24 #include "libpandabase/macros.h"
25 #include "runtime/include/mem/panda_containers.h"
26 #include "runtime/include/mem/panda_smart_pointers.h"
27 #include "runtime/include/mem/panda_string.h"
28 
29 namespace panda {
30 
31 class Class;
32 class Method;
33 class Runtime;
34 class RuntimeListener;
35 
36 /**
37  * The DProfiler class integrates the distributed profiling in the Panda.
38  */
39 class DProfiler final {
40 public:
41     DProfiler(std::string_view app_name, Runtime *runtime);
42     ~DProfiler() = default;
43 
44     /**
45      * Add a panda::Class for the dump.
46      * @param klass
47      */
48     void AddClass(const Class *klass);
49 
50     /**
51      * Send a dump of distributed profiling info
52      */
53     void Dump();
54 
55 private:
56     Runtime *runtime_;
57     PandaUniquePtr<dprof::ProfilingData> profiling_data_;
58     PandaUniquePtr<RuntimeListener> listener_;
59     PandaUnorderedSet<const Method *> hot_methods_;
60 
61     NO_COPY_SEMANTIC(DProfiler);
62     NO_MOVE_SEMANTIC(DProfiler);
63 };
64 
65 }  // namespace panda
66 
67 #endif  // PANDA_RUNTIME_DPROFILER_DPROFILER_H_
68