Files
MuditaOS/module-sys/SystemManager/CpuLogPrinter.cpp
Adam Dobrowolski dd12853503 [MOS-226] Moved algorithms and their data to separate classes
This way we have controll over what does what, and can test
them separatelly
Logging statistics update more and better data presented
2022-03-04 07:05:02 +01:00

51 lines
1.7 KiB
C++

// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "SystemManager/CpuPrinter.hpp"
#include "SystemManager/SysCpuUpdateResult.hpp"
#include <SystemManager/SystemManagerCommon.hpp>
extern "C"
{
uint32_t CLOCK_GetFreq(int);
}
namespace sys::cpu::stats
{
void LogPrinter::printSysUsage(struct task_prof_data *data, size_t size)
{
vTaskSuspendAll();
{
for (size_t i = 0; i < size; ++i) {
if (data[i].exec_time == 0 && data[i].switches == 0) {
continue;
}
LOG_PRINTF("%s,%" PRIu32 ",%" PRIu32 ",%" PRIu32 "\n",
SystemManagerCommon::ServiceProcessor(i).c_str(),
data[i].task_TCB_id,
data[i].exec_time,
data[i].switches);
/// NOTE: version below is much lighter and doesn't need system suspend, it requires GDB to show what
/// were the
// task names LOG_PRINTF("%d,%" PRIu32 "\n", data[i].task_TCB_id, data[i].exec_time);
}
}
xTaskResumeAll();
}
void LogPrinter::printCPUChange(const cpu::UpdateResult &ret)
{
LOG_PRINTF("CPU freq changed to: %d by: %s reason: %s for freq: %d curent: %" PRIu32 "\n",
int(ret.frequencySet),
ret.data.name.c_str(),
ret.data.reason.c_str(),
int(ret.data.frequency),
CLOCK_GetFreq(0));
}
void LogPrinter::printPowerConsumption()
{}
} // namespace sys::cpu::stats