1 /* 2 * Copyright (c) 2023 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 HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_PERF_DECORATOR_H 17 #define HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_PERF_DECORATOR_H 18 19 #include "perf_collector.h" 20 #include "decorator.h" 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 namespace UCollectUtil { 25 class PerfDecorator : public PerfCollector, public UCDecorator { 26 public: PerfDecorator(std::shared_ptr<PerfCollector> collector)27 PerfDecorator(std::shared_ptr<PerfCollector> collector) : perfCollector_(collector) {}; 28 virtual ~PerfDecorator() = default; 29 virtual CollectResult<bool> StartPerf(const std::string &logDir) override; 30 void SetSelectPids(const std::vector<pid_t> &selectPids) override; 31 void SetTargetSystemWide(bool enable) override; 32 void SetTimeStopSec(int timeStopSec) override; 33 void SetFrequency(int frequency) override; 34 void SetOffCPU(bool offCPU) override; 35 void SetOutputFilename(const std::string &outputFilename) override; 36 void SetCallGraph(const std::string &sampleTypes) override; 37 void SetSelectEvents(const std::vector<std::string> &selectEvents) override; 38 void SetCpuPercent(int cpuPercent) override; 39 void SetReport(bool enable) override; 40 static void SaveStatCommonInfo(); 41 static void ResetStatInfo(); 42 // for prepare recod mode 43 CollectResult<bool> Prepare(const std::string &logDir) override; 44 CollectResult<bool> StartRun() override; 45 CollectResult<bool> Pause() override; 46 CollectResult<bool> Resume() override; 47 CollectResult<bool> Stop() override; 48 49 private: 50 std::shared_ptr<PerfCollector> perfCollector_; 51 static StatInfoWrapper statInfoWrapper_; 52 }; 53 } // namespace UCollectUtil 54 } // namespace HiviewDFX 55 } // namespace OHOS 56 #endif // HIVIEW_FRAMEWORK_NATIVE_UNIFIED_COLLECTION_PERF_DECORATOR_H 57