From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28953A0487 for ; Mon, 29 Jul 2019 14:37:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0FC3C1BF79; Mon, 29 Jul 2019 14:37:14 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 57E6D1BF5C for ; Mon, 29 Jul 2019 14:37:08 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Jul 2019 15:37:07 +0300 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6TCb7Vl009212; Mon, 29 Jul 2019 15:37:07 +0300 From: Matan Azrad To: Wenzhuo Lu , Jingjing Wu Cc: dev@dpdk.org Date: Mon, 29 Jul 2019 12:36:57 +0000 Message-Id: <1564403817-13438-2-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564403817-13438-1-git-send-email-matan@mellanox.com> References: <1564403817-13438-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH 2/2] app/testpmd: add bits per second to statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Traffic bps statistics is very useful for performance testing. Add bits per second statistics for Rx and Tx. Signed-off-by: Matan Azrad --- app/test-pmd/config.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1a5a5c1..88bc716 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -119,9 +119,12 @@ { static uint64_t prev_pkts_rx[RTE_MAX_ETHPORTS]; static uint64_t prev_pkts_tx[RTE_MAX_ETHPORTS]; + static uint64_t prev_bytes_rx[RTE_MAX_ETHPORTS]; + static uint64_t prev_bytes_tx[RTE_MAX_ETHPORTS]; static uint64_t prev_cycles[RTE_MAX_ETHPORTS]; - uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles; - uint64_t mpps_rx, mpps_tx; + uint64_t diff_pkts_rx, diff_pkts_tx, diff_bytes_rx, diff_bytes_tx, + diff_cycles; + uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx; struct rte_eth_stats stats; struct rte_port *port = &ports[port_id]; uint8_t i; @@ -192,9 +195,22 @@ diff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0; mpps_tx = diff_cycles > 0 ? diff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0; + + diff_bytes_rx = (stats.ibytes > prev_bytes_rx[port_id]) ? + (stats.ibytes - prev_bytes_rx[port_id]) : 0; + diff_bytes_tx = (stats.obytes > prev_bytes_tx[port_id]) ? + (stats.obytes - prev_bytes_tx[port_id]) : 0; + prev_bytes_rx[port_id] = stats.ibytes; + prev_bytes_tx[port_id] = stats.obytes; + mbps_rx = diff_cycles > 0 ? + diff_bytes_rx * rte_get_tsc_hz() / diff_cycles : 0; + mbps_tx = diff_cycles > 0 ? + diff_bytes_tx * rte_get_tsc_hz() / diff_cycles : 0; + printf("\n Throughput (since last show)\n"); - printf(" Rx-pps: %12"PRIu64"\n Tx-pps: %12"PRIu64"\n", - mpps_rx, mpps_tx); + printf(" Rx-pps: %12"PRIu64" Rx-bps: %12"PRIu64"\n Tx-pps: %12" + PRIu64" Tx-bps: %12"PRIu64"\n", mpps_rx, mbps_rx * 8, + mpps_tx, mbps_tx * 8); printf(" %s############################%s\n", nic_stats_border, nic_stats_border); -- 1.8.3.1