Skip to content

Commit

Permalink
perf_cnt: simplify the difference calculation for cycles
Browse files Browse the repository at this point in the history
Previously, due to cycle get max is UINT32_MAX, so check
and wrap cycles based on INT32_MAX, however, unsigned int can wrap
automatically with minus, remove the check and make
perf difference calculation more simple.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
  • Loading branch information
btian1 authored and ranj063 committed Jul 6, 2023
1 parent 2fb0c1d commit 8adbb85
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions xtos/include/sof/lib/perf_cnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,8 @@ struct perf_cnt_data {
(uint32_t)sof_cycle_get_64(); \
uint32_t cpu_ts = \
(uint32_t)perf_cnt_get_cpu_ts(); \
if (plat_ts > (pcd)->plat_ts) \
(pcd)->plat_delta_last = plat_ts - (pcd)->plat_ts; \
else \
(pcd)->plat_delta_last = UINT32_MAX - (pcd)->plat_ts \
+ plat_ts; \
if (cpu_ts > (pcd)->cpu_ts) \
(pcd)->cpu_delta_last = cpu_ts - (pcd)->cpu_ts; \
else \
(pcd)->cpu_delta_last = UINT32_MAX - (pcd)->cpu_ts \
+ cpu_ts;\
(pcd)->plat_delta_last = plat_ts - (pcd)->plat_ts; \
(pcd)->cpu_delta_last = cpu_ts - (pcd)->cpu_ts; \
if ((pcd)->plat_delta_last > (pcd)->plat_delta_peak) \
(pcd)->plat_delta_peak = (pcd)->plat_delta_last; \
if ((pcd)->cpu_delta_last > (pcd)->cpu_delta_peak) { \
Expand Down

0 comments on commit 8adbb85

Please sign in to comment.