diff --git a/smartperf_device/device_command/collector/include/CPU.h b/smartperf_device/device_command/collector/include/CPU.h index eac3bb4bd553e1c4ddb4b08dde922dcf4f791ea9..b34fc41ff70817dff6884a07c678b0e55c2e2250 100644 --- a/smartperf_device/device_command/collector/include/CPU.h +++ b/smartperf_device/device_command/collector/include/CPU.h @@ -52,6 +52,7 @@ public: std::map GetCpuCoreCurFreqs(); void GetCpuFreqItemData(std::map &cpuFreqResult); void GetCpuUsageItemData(std::map &cpuUsageResult); + void SetCoreCurFreqFlag(); private: CPU() {}; CPU(const CPU &); @@ -62,6 +63,7 @@ private: const std::string totalcpu = "Totalcpu"; int twenty = 20; int thousand = 1000; + bool coreCurFreqFlag = false; }; } } diff --git a/smartperf_device/device_command/collector/src/CPU.cpp b/smartperf_device/device_command/collector/src/CPU.cpp index 8fed0fd16bbced78b7e566553b9ad11c9ea45247..fdc9aeaa8cfd9f27f9f8c281318250666e70b318 100644 --- a/smartperf_device/device_command/collector/src/CPU.cpp +++ b/smartperf_device/device_command/collector/src/CPU.cpp @@ -52,9 +52,11 @@ std::map CPU::ItemData() } } - std::map cpuCoreCurFreqs = GetCpuCoreCurFreqs(); - for (const auto& item : cpuCoreCurFreqs) { - result[item.first] = item.second; + if (coreCurFreqFlag) { + std::map cpuCoreCurFreqs = GetCpuCoreCurFreqs(); + for (const auto& item : cpuCoreCurFreqs) { + result[item.first] = item.second; + } } LOGI("CPU:ItemData map size(%u)", result.size()); @@ -258,5 +260,10 @@ std::map CPU::GetCpuCoreCurFreqs() } return cpuCoreCurFreqs; } + +void CPU::SetCoreCurFreqFlag() +{ + coreCurFreqFlag = true; +} } } diff --git a/smartperf_device/device_command/services/ipc/src/sp_thread_socket.cpp b/smartperf_device/device_command/services/ipc/src/sp_thread_socket.cpp index dd78055d209731c3d8137be8342d834097b0590b..f24ee7f3cd106595c7c3d26d2dbaebc716d16059 100644 --- a/smartperf_device/device_command/services/ipc/src/sp_thread_socket.cpp +++ b/smartperf_device/device_command/services/ipc/src/sp_thread_socket.cpp @@ -45,6 +45,7 @@ #include "include/RAM.h" #include "include/FPS.h" #include "include/hiperf.h" +#include "include/CPU.h" #define SMARTPERF "smartperf" namespace OHOS { @@ -780,6 +781,7 @@ void SpThreadSocket::UdpStartMessProcess(SpServerSocket &spSocket, SpProfiler *p taskMgr_->AddTask(&SdkDataRecv::GetInstance(), false); } bytrace.ClearTraceFiles(); + CPU::GetInstance().SetCoreCurFreqFlag(); StartHapCollecting(spSocket); } else if (iterator->first == MessageType::APP_RECEIVE_DATA_ON) { if (taskMgr_ != nullptr) { diff --git a/smartperf_device/device_command/services/task_mgr/src/task_manager.cpp b/smartperf_device/device_command/services/task_mgr/src/task_manager.cpp index ba3112ff88c476e9a63e3473b0f4cbcb0c688267..237d6797a5047b60914fab0150bb958a20b0481e 100644 --- a/smartperf_device/device_command/services/task_mgr/src/task_manager.cpp +++ b/smartperf_device/device_command/services/task_mgr/src/task_manager.cpp @@ -490,7 +490,7 @@ std::string TaskManager::MapToString(std::map& myMap) "cpu7Frequency", "cpu8Frequency", "cpu9Frequency", "cpu10Frequency", "cpu11Frequency", "gpuFrequency", "pss", "shell_frame", "shell_back", "soc_thermal", "cpu0Usage", "cpu1Usage", "cpu2Usage", "cpu3Usage", "cpu4Usage", "cpu5Usage", "cpu6Usage", "cpu7Usage", "cpu8Usage", "cpu9Usage", "cpu10Usage", "cpu11Usage", - "gpuLoad"}; + "gpuLoad", "cpu0_curFrequency", "cpu1_curFrequency", "cpu2_curFrequency"}; for (const auto& key : keysToFind) { if (auto iter = myMap.find(key); iter != myMap.end()) { appCollectMap += iter->first + ":" + iter->second + ",";