diff mbox series

[1/1] test: generator: Updated global stats calculation to provide useful/easy-to-parse information

Message ID CADjer37pgvCrByY+npxewadDfXk4rJMrqf1qn5f=QJ021inepg@mail.gmail.com
State Superseded
Headers show
Series [1/1] test: generator: Updated global stats calculation to provide useful/easy-to-parse information | expand

Commit Message

Bogdan Pricope Feb. 7, 2017, 8:51 a.m. UTC
Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
 example/generator/odp_generator.c | 58 +++++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 23 deletions(-)

-- 
1.9.1
diff mbox series

Patch

diff --git a/example/generator/odp_generator.c
b/example/generator/odp_generator.c
index ccd47f6..39bf026 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -569,7 +569,10 @@  static int gen_recv_thread(void *arg)
 static void print_global_stats(int num_workers)
 {
     odp_time_t cur, wait, next;
-    uint64_t pkts, pkts_prev = 0, pps, maximum_pps = 0;
+    uint64_t pkts_snd = 0, pkts_snd_prev = 0;
+    uint64_t pps_snd = 0, maximum_pps_snd = 0;
+    uint64_t pkts_rcv = 0, pkts_rcv_prev = 0;
+    uint64_t pps_rcv = 0, maximum_pps_rcv = 0;
     int verbose_interval = 20;
     odp_thrmask_t thrd_mask;

@@ -590,30 +593,39 @@  static void print_global_stats(int num_workers)
             continue;

         next = odp_time_sum(cur, wait);
-
-        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);
+        switch (args->appl.mode)
+        {
+            case APPL_MODE_RCV:
+                pkts_rcv = odp_atomic_load_u64(&counters.ip);
+                break;
+            case APPL_MODE_PING:
+                pkts_snd = odp_atomic_load_u64(&counters.seq);
+                pkts_rcv = odp_atomic_load_u64(&counters.icmp);
+                break;
+            case APPL_MODE_UDP:
+                pkts_snd = odp_atomic_load_u64(&counters.seq);
+                break;
+            default:
+                continue;
         }

-        pkts = odp_atomic_load_u64(&counters.seq);
-        printf(" total sent: %" PRIu64 ", drops: %" PRIu64 "\n", pkts,
-               odp_atomic_load_u64(&counters.tx_drops));
-
-        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;
-        }
+        pps_snd = (pkts_snd - pkts_snd_prev) / verbose_interval;
+        pkts_snd_prev = pkts_snd;
+        if (pps_snd > maximum_pps_snd)
+            maximum_pps_snd = pps_snd;
+
+        pps_rcv = (pkts_rcv - pkts_rcv_prev) / verbose_interval;
+        pkts_rcv_prev = pkts_rcv;
+        if (pps_rcv > maximum_pps_rcv)
+            maximum_pps_rcv = pps_rcv;
+
+        printf("sent: %" PRIu64 ", drops: %" PRIu64 ", "
+            "send rate: %" PRIu64 " pps, max send rate: %" PRIu64 " pps, "
+            "rcv: %" PRIu64 ", "
+            "recv rate: %" PRIu64 " pps, max recv rate: %" PRIu64 " pps\n",
+            pkts_snd, odp_atomic_load_u64(&counters.tx_drops),
+            pps_snd, maximum_pps_snd,
+            pkts_rcv, pps_rcv, maximum_pps_rcv);
     }
 }