This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 1bd81b5a78da29715c8df4797b725226b8f1bb9c Author: ganjing <[email protected]> AuthorDate: Fri Nov 13 14:58:53 2026 +0800 benchmarks/cyclictest: Map the -c option to the clock names. The -c option takes 0 for CLOCK_REALTIME and 1 for CLOCK_MONOTONIC, but the code used the number as the clock ID, which only works while the clock IDs have these values. Map 0 and 1 to the clock names. Also fix the nxstyle errors in the file. Assisted-by: Kiro:auto Signed-off-by: ganjing <[email protected]> --- benchmarks/cyclictest/cyclictest.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/benchmarks/cyclictest/cyclictest.c b/benchmarks/cyclictest/cyclictest.c index fb9382dd5..948f11f53 100644 --- a/benchmarks/cyclictest/cyclictest.c +++ b/benchmarks/cyclictest/cyclictest.c @@ -206,6 +206,7 @@ static long arg_decimal(char *arg) { long ret; char *endptr; + ret = strtol(arg, &endptr, 10); if (endptr == arg) { @@ -220,6 +221,7 @@ static bool parse_args(int argc, char * const argv[]) int longindex; int opt; long decimal; + while ((opt = getopt_long(argc, argv, "c:d:D:h:Hi:l:m:n:p:qt:T:", optargs, &longindex)) != -1) { @@ -231,9 +233,13 @@ static bool parse_args(int argc, char * const argv[]) { return false; } - else if (decimal == CLOCK_MONOTONIC || decimal == CLOCK_REALTIME) + else if (decimal == 0) { - config.clock = decimal; + config.clock = CLOCK_REALTIME; + } + else if (decimal == 1) + { + config.clock = CLOCK_MONOTONIC; } break; case 'd': @@ -443,6 +449,7 @@ static inline void tsnorm(struct timespec *ts) static inline int64_t timediff_us(struct timespec t1, struct timespec t2) { int64_t ret; + ret = 1000000 * (t1.tv_sec - t2.tv_sec); ret += (t1.tv_nsec - t2.tv_nsec) / 1000; return ret; @@ -454,6 +461,7 @@ static inline int64_t timediff_us_timer(struct timer_status_s after, int64_t ret = 0; uint32_t t1; uint32_t t2; + t1 = before.timeleft; t2 = after.timeleft; if (t2 < t1) @@ -732,6 +740,7 @@ static void print_hist(struct thread_param_s *par[], int nthreads) for (j = 0; j < nthreads; j++) { unsigned long curr_latency = par[j]->stats->hist_array[i]; + printf("%06lu", curr_latency); if (j < nthreads - 1) { @@ -824,6 +833,7 @@ static void print_stat(struct thread_param_s *par, int index) { struct thread_stats_s *stat = par->stats; char *fmt; + fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu " "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n"; printf(fmt, index, stat->tid, par->prio, par->interval, stat->cycles, @@ -1038,6 +1048,7 @@ int main(int argc, char *argv[]) usleep(100 * 1000); int ended = 0; + for (i = 0; i < config.threads; ++i) { if (!config.quiet)
