1 /* 2 * Copyright (c) 2025 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 LITE_PERF_H 16 #define LITE_PERF_H 17 18 #include <memory> 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace HiviewDFX { 24 class LitePerf { 25 public: 26 LitePerf(); 27 ~LitePerf() = default; 28 LitePerf(const LitePerf&) = delete; 29 LitePerf& operator=(const LitePerf&) = delete; 30 31 /** 32 * @brief Start process stack sampling 33 * 34 * @param tids thread ids 35 * @param freq freq 36 * @param durationMs duration ms 37 * @param parseMiniDebugInfo whether parse MiniDebugInfo 38 * @return if succeed return 0, otherwise return -1 39 */ 40 int StartProcessStackSampling(const std::vector<int>& tids, int freq, int durationMs, bool parseMiniDebugInfo); 41 42 /** 43 * @brief Collect process stack sampling By tid 44 * 45 * @param tid thread id 46 * @param stack stack of thread id 47 * @return if succeed return 0, otherwise return -1 48 */ 49 int CollectSampleStackByTid(int tid, std::string& stack); 50 51 /** 52 * @brief Finish process stack sampling 53 * 54 * @return if succeed return 0, otherwise return -1 55 */ 56 int FinishProcessStackSampling(); 57 58 private: 59 class Impl; 60 std::shared_ptr<Impl> impl_; 61 }; 62 } // namespace HiviewDFX 63 } // namespace OHOS 64 #endif // LITE_PERF_H