From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 347565A17 for ; Fri, 6 May 2016 07:52:25 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 05 May 2016 22:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,585,1455004800"; d="scan'208";a="960027705" Received: from unknown (HELO dpdk5.sh.intel.com) ([10.239.129.244]) by fmsmga001.fm.intel.com with ESMTP; 05 May 2016 22:52:23 -0700 From: Zhihong Wang To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, bruce.richardson@intel.com, thomas.monjalon@6wind.com, Zhihong Wang Date: Thu, 5 May 2016 18:46:58 -0400 Message-Id: <1462488421-118990-4-git-send-email-zhihong.wang@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1462488421-118990-1-git-send-email-zhihong.wang@intel.com> References: <1462488421-118990-1-git-send-email-zhihong.wang@intel.com> Subject: [dpdk-dev] [PATCH 3/6] testpmd: show throughput in port stats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2016 05:52:25 -0000 This patch adds throughput numbers (in the period since last use of this command) in port statistics display for "show port stats (port_id|all)". Signed-off-by: Zhihong Wang --- app/test-pmd/config.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1c552e4..bb0b542 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -92,6 +92,7 @@ #include #include #include +#include #include "testpmd.h" @@ -150,6 +151,10 @@ print_ethaddr(const char *name, struct ether_addr *eth_addr) void nic_stats_display(portid_t port_id) { + static uint64_t sum_rx[RTE_MAX_ETHPORTS]; + static uint64_t sum_tx[RTE_MAX_ETHPORTS]; + static uint64_t cycles[RTE_MAX_ETHPORTS]; + uint64_t pkt_rx, pkt_tx, cycle; struct rte_eth_stats stats; struct rte_port *port = &ports[port_id]; uint8_t i; @@ -209,6 +214,21 @@ nic_stats_display(portid_t port_id) } } + cycle = cycles[port_id]; + cycles[port_id] = rte_rdtsc(); + if (cycle > 0) + cycle = cycles[port_id] - cycle; + + pkt_rx = stats.ipackets - sum_rx[port_id]; + pkt_tx = stats.opackets - sum_tx[port_id]; + sum_rx[port_id] = stats.ipackets; + sum_tx[port_id] = stats.opackets; + printf("\n Throughput (since last show)\n"); + printf(" RX-pps: %12"PRIu64"\n" + " TX-pps: %12"PRIu64"\n", + cycle > 0 ? pkt_rx * rte_get_tsc_hz() / cycle : 0, + cycle > 0 ? pkt_tx * rte_get_tsc_hz() / cycle : 0); + printf(" %s############################%s\n", nic_stats_border, nic_stats_border); } -- 2.5.0