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

Message ID 1489564113-7856-2-git-send-email-bogdan.pricope@linaro.org
State New
Headers show

Commit Message

Bogdan Pricope March 15, 2017, 7:48 a.m.
Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

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

-- 
1.9.1

Patch hide | download patch | download mbox

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 8062d87..adb94cc 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -568,7 +568,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;
 
@@ -589,30 +592,40 @@  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);
+		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;
 		}
 
-		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 ", 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);
 	}
 }