introduce __perf_counter_printf__

This commit is contained in:
Gabriel Wang 2022-06-15 12:03:28 +01:00
parent f113b98b93
commit 2e5402f613

View File

@ -269,6 +269,9 @@ extern "C" {
__set_PRIMASK(SAFE_NAME(temp))) __set_PRIMASK(SAFE_NAME(temp)))
#endif #endif
#ifndef __perf_counter_printf__
# define __perf_counter_printf__ printf
#endif
#if __PLOOC_VA_NUM_ARGS() != 0 #if __PLOOC_VA_NUM_ARGS() != 0
#warning Please enable GNC extensions, it is required by __cycleof__() and \ #warning Please enable GNC extensions, it is required by __cycleof__() and \
@ -283,10 +286,12 @@ __super_loop_monitor__()
_ = get_system_ticks() - _; \ _ = get_system_ticks() - _; \
__cycle_count__ = _; \ __cycle_count__ = _; \
if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \ if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \
printf("\r\n"); \ __perf_counter_printf__("\r\n"); \
printf("-[Cycle Report]"); \ __perf_counter_printf__("-[Cycle Report]"); \
printf("--------------------------------------------\r\n"); \ __perf_counter_printf__( \
printf(__STR " total cycle count: %d [%08x]\r\n", \ "--------------------------------------------\r\n"); \
__perf_counter_printf__( \
__STR " total cycle count: %d [%08x]\r\n", \
(int)_, (int)_); \ (int)_, (int)_); \
} else { \ } else { \
__VA_ARGS__ \ __VA_ARGS__ \
@ -310,7 +315,8 @@ __super_loop_monitor__()
__cpu_usage__.lTaskUsedCycles = stop_task_cycle_counter(); \ __cpu_usage__.lTaskUsedCycles = stop_task_cycle_counter(); \
\ \
if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \ if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \
printf("%s CPU Usage %2.3f%%\r\n", __func__, \ __perf_counter_printf__( \
"%s CPU Usage %2.3f%%\r\n", __func__, \
(float)((double)__cpu_usage__.lTaskUsedCycles * 100.0 / \ (float)((double)__cpu_usage__.lTaskUsedCycles * 100.0 / \
(double)__cpu_usage__.lTimeElapsed)); \ (double)__cpu_usage__.lTimeElapsed)); \
} else { \ } else { \