• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 #ifndef PANDA_RUNTIME_DPROFILER_DPROFILER_H_
16 #define PANDA_RUNTIME_DPROFILER_DPROFILER_H_
17 
18 #include <memory>
19 #include <string>
20 #include <unordered_set>
21 
22 #include "dprof/profiling_data.h"
23 #include "libpandabase/macros.h"
24 #include "runtime/include/mem/panda_containers.h"
25 #include "runtime/include/mem/panda_smart_pointers.h"
26 #include "runtime/include/mem/panda_string.h"
27 
28 namespace panda {
29 
30 class Class;
31 class Method;
32 class Runtime;
33 class RuntimeListener;
34 
35 /**
36  * \brief The DProfiler class integrates the distributed profiling in the Panda.
37  */
38 class DProfiler final {
39 public:
40 #ifdef PANDA_TARGET_UNIX
41     DProfiler(std::string_view app_name, Runtime *runtime);
42 #else
43     DProfiler([[maybe_unused]] std::string_view app_name, [[maybe_unused]] Runtime *runtime)
44     {
45         // Unsupported on windows platform
46         UNREACHABLE();
47     }
48 #endif  // PANDA_TARGET_UNIX
49     ~DProfiler() = default;
50 
51     /**
52      * \brief Add a panda::Class for the dump.
53      * @param klass
54      */
55     void AddClass(const Class *klass);
56 
57     /**
58      * \brief Send a dump of distributed profiling info
59      */
60     void Dump();
61 
62 private:
63     Runtime *runtime_;
64     PandaUniquePtr<dprof::ProfilingData> profiling_data_;
65     PandaUniquePtr<RuntimeListener> listener_;
66     PandaUnorderedSet<const Method *> hot_methods_;
67 
68     NO_COPY_SEMANTIC(DProfiler);
69     NO_MOVE_SEMANTIC(DProfiler);
70 };
71 
72 }  // namespace panda
73 
74 #endif  // PANDA_RUNTIME_DPROFILER_DPROFILER_H_
75