1 /* 2 * Copyright (c) 2024 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __BENCHMARK_WAITQ_UTILS_H 8 #define __BENCHMARK_WAITQ_UTILS_H 9 /* 10 * @brief This file contains macros used in the wait queue benchmarking. 11 */ 12 13 #include <zephyr/sys/printk.h> 14 15 #ifdef CSV_FORMAT_OUTPUT 16 #define FORMAT_STR "%-74s,%s,%s\n" 17 #define CYCLE_FORMAT "%8u" 18 #define NSEC_FORMAT "%8u" 19 #else 20 #define FORMAT_STR "%-74s:%s , %s\n" 21 #define CYCLE_FORMAT "%8u cycles" 22 #define NSEC_FORMAT "%8u ns" 23 #endif 24 25 /** 26 * @brief Display a line of statistics 27 * 28 * This macro displays the following: 29 * 1. Test description summary 30 * 2. Number of cycles 31 * 3. Number of nanoseconds 32 */ 33 #define PRINT_F(summary, cycles, nsec) \ 34 do { \ 35 char cycle_str[32]; \ 36 char nsec_str[32]; \ 37 \ 38 snprintk(cycle_str, 30, CYCLE_FORMAT, cycles); \ 39 snprintk(nsec_str, 30, NSEC_FORMAT, nsec); \ 40 printk(FORMAT_STR, summary, cycle_str, nsec_str); \ 41 } while (0) 42 43 #define PRINT_STATS_AVG(summary, value, counter) \ 44 PRINT_F(summary, value / counter, \ 45 (uint32_t)timing_cycles_to_ns_avg(value, counter)) 46 47 #endif 48