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 #ifndef INTERFACES_INNER_API_UNIFIED_COLLECTION_RESOURCE_CPU_H 16 #define INTERFACES_INNER_API_UNIFIED_COLLECTION_RESOURCE_CPU_H 17 #include <cinttypes> 18 #include <string> 19 #include <vector> 20 21 namespace OHOS { 22 namespace HiviewDFX { 23 struct SysCpuLoad { 24 double avgLoad1; 25 double avgLoad5; 26 double avgLoad15; 27 }; 28 29 struct CpuUsageInfo { 30 std::string cpuId; 31 double userUsage = 0; 32 double niceUsage = 0; 33 double systemUsage = 0; 34 double idleUsage = 0; 35 double ioWaitUsage = 0; 36 double irqUsage = 0; 37 double softIrqUsage = 0; 38 }; 39 40 struct SysCpuUsage { 41 uint64_t startTime = 0; 42 uint64_t endTime = 0; 43 std::vector<CpuUsageInfo> cpuInfos; 44 }; 45 46 struct CpuFreq { 47 uint32_t cpuId = 0; 48 uint32_t curFreq = 0; 49 uint32_t minFreq = 0; 50 uint32_t maxFreq = 0; 51 }; 52 53 struct ProcessCpuStatInfo { 54 uint64_t startTime = 0; 55 uint64_t endTime = 0; 56 int32_t pid = 0; 57 uint32_t minFlt = 0; 58 uint32_t majFlt = 0; 59 double cpuLoad = 0; 60 double uCpuUsage = 0; 61 double sCpuUsage = 0; 62 double cpuUsage = 0; 63 std::string procName; 64 int32_t threadCount = 0; 65 }; 66 67 struct ThreadCpuStatInfo { 68 uint64_t startTime = 0; 69 uint64_t endTime = 0; 70 int32_t tid = 0; 71 double cpuLoad = 0; 72 double uCpuUsage = 0; 73 double sCpuUsage = 0; 74 double cpuUsage = 0; 75 }; 76 } // HiviewDFX 77 } // OHOS 78 #endif // INTERFACES_INNER_API_UNIFIED_COLLECTION_RESOURCE_CPU_H