diff options
author | Jere Leppänen <jere.leppanen@nokia.com> | 2022-09-26 11:45:32 +0300 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2022-10-20 12:17:21 +0300 |
commit | 34dad5d640cef20a959bfef5995061ae22c81adb (patch) | |
tree | 60f9729a1152643f9229c90b9a0183b8c4c544a2 /example | |
parent | 747b52cda64c9d729649c686a5e7e45ac905259e (diff) |
example: classifier: print packet rate
Print packet rate in Mpps. Print statistics for every interval on a
new line, instead of updating a single line.
Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'example')
-rw-r--r-- | example/classifier/odp_classifier.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/example/classifier/odp_classifier.c b/example/classifier/odp_classifier.c index 297e28620..8e077629c 100644 --- a/example/classifier/odp_classifier.c +++ b/example/classifier/odp_classifier.c @@ -175,7 +175,7 @@ static inline void print_cls_statistics(appl_args_t *args) printf("\n"); for (i = 0; i < args->policy_count; i++) printf("%-12s |", args->stats[i].cos_name); - printf("Total Packets"); + printf("%-6s %-6s", "Total", "Mpps"); printf("\n"); for (i = 0; i < args->policy_count; i++) printf("%-6s %-6s|", "queue", "pool"); @@ -188,9 +188,12 @@ static inline void print_cls_statistics(appl_args_t *args) if (timeout == 0) infinite = 1; + uint64_t total_packets, last_total_packets = 0; + odp_time_t start = odp_time_local(), end; + float mpps; + for (; timeout > 0 || infinite; timeout--) { sleep(1); - printf("\r"); for (i = 0; i < args->policy_count; i++) { printf("%-6" PRIu64 " ", odp_atomic_load_u64(&args->stats[i] @@ -200,9 +203,13 @@ static inline void print_cls_statistics(appl_args_t *args) .pool_pkt_count)); } - printf("%-" PRIu64, odp_atomic_load_u64(&args-> - total_packets)); - fflush(stdout); + end = odp_time_local(); + total_packets = odp_atomic_load_u64(&args->total_packets); + mpps = (total_packets - last_total_packets) / + (odp_time_diff_ns(end, start) / 1000.0); + printf("%-6" PRIu64 " %-6.3f\n", total_packets, mpps); + last_total_packets = total_packets; + start = end; if (args->shutdown_sig) break; |