From: Grigore Ion <[email protected]>

The statistics are displayed at a fixed time interval. If the configured
number of packets is processed before this interval expires, no statistic
is shown. If many packets are processed it is very possible the last
statistic is not displayed.

Signed-off-by: Grigore Ion <[email protected]>
---
 example/generator/odp_generator.c |   61 +++++++++++++++++++++++--------------
 1 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/example/generator/odp_generator.c 
b/example/generator/odp_generator.c
index 34fb226..ab592bd 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -103,6 +103,7 @@ static void usage(char *progname);
 static int scan_ip(char *buf, unsigned int *paddr);
 static int scan_mac(char *in, odph_ethaddr_t *des);
 static void tv_sub(struct timeval *recvtime, struct timeval *sendtime);
+static void print_on_time_expire_stats(int verbose_interval);
 static void print_global_stats(int num_workers);
 
 /**
@@ -581,13 +582,45 @@ static void *gen_recv_thread(void *arg)
 }
 
 /**
+ * printing on time interval expiration statistics
+ *
+ */
+static void print_on_time_expire_stats(int verbose_interval)
+{
+       uint64_t        pkts, pps;
+       static uint64_t pkts_prev, maximum_pps;
+
+       if (args->appl.mode == APPL_MODE_RCV) {
+               pkts = odp_atomic_load_u64(&counters.udp);
+               printf(" total receive(UDP: %" PRIu64 ")\n", pkts);
+               return;
+       }
+
+       if (args->appl.mode == APPL_MODE_PING) {
+               pkts = odp_atomic_load_u64(&counters.icmp);
+               printf(" total receive(ICMP: %" PRIu64 ")\n", pkts);
+       }
+
+       pkts = odp_atomic_load_u64(&counters.seq);
+       printf(" total sent: %" PRIu64 "\n", pkts);
+
+       if (args->appl.mode == APPL_MODE_UDP) {
+               pps = (pkts - pkts_prev) / verbose_interval;
+               if (pps > maximum_pps)
+                       maximum_pps = pps;
+               printf(" %" PRIu64 " pps, %" PRIu64 " max pps\n",
+                      pps, maximum_pps);
+               pkts_prev = pkts;
+       }
+}
+
+/**
  * printing verbose statistics
  *
  */
 static void print_global_stats(int num_workers)
 {
        uint64_t start, now, diff;
-       uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0;
        int verbose_interval = 20;
        odp_thrmask_t thrd_mask;
 
@@ -612,29 +645,11 @@ static void print_global_stats(int num_workers)
 
                start = odp_time_cycles();
 
-               if (args->appl.mode == APPL_MODE_RCV) {
-                       pkts = odp_atomic_load_u64(&counters.udp);
-                       printf(" total receive(UDP: %" PRIu64 ")\n", pkts);
-                       continue;
-               }
-
-               if (args->appl.mode == APPL_MODE_PING) {
-                       pkts = odp_atomic_load_u64(&counters.icmp);
-                       printf(" total receive(ICMP: %" PRIu64 ")\n", pkts);
-               }
-
-               pkts = odp_atomic_load_u64(&counters.seq);
-               printf(" total sent: %" PRIu64 "\n", pkts);
-
-               if (args->appl.mode == APPL_MODE_UDP) {
-                       pps = (pkts - pkts_prev) / verbose_interval;
-                       if (pps > maximum_pps)
-                               maximum_pps = pps;
-                       printf(" %" PRIu64 " pps, %" PRIu64 " max pps\n",
-                              pps, maximum_pps);
-                       pkts_prev = pkts;
-               }
+               print_on_time_expire_stats(verbose_interval);
        }
+       /* Print remaining statistics */
+       if (odp_time_cycles_to_ns(diff) < verbose_interval * ODP_TIME_SEC)
+               print_on_time_expire_stats(verbose_interval);
 }
 
 /**
-- 
1.7.3.4

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to