[v2,2/5] app/testpmd: print fractional part in CPU cycles

Message ID 20200508223829.3228-2-dharmik.thakkar@arm.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2,1/5] app/testpmd: print clock with CPU cycles per pkt |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Dharmik Thakkar May 8, 2020, 10:38 p.m. UTC
  Change printing of CPU cycles/packet to include fractional part for
accurateness.

Example:

Without patch:
CPU cycles/packet=14
(total cycles=4899533541 / total RX packets=343031966)

With patch:
CPU cycles/packet=14.28
(total cycles=4899533541 / total RX packets=343031966)

Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Phil Yang <phil.yang@arm.com>
---
v2:
 - Change typecast to (double) fwd_cycles / total_recv

---
 app/test-pmd/testpmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Iremonger, Bernard May 12, 2020, 10:19 a.m. UTC | #1
> -----Original Message-----
> From: Dharmik Thakkar <dharmik.thakkar@arm.com>
> Sent: Friday, May 8, 2020 11:38 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Cc: dev@dpdk.org; nd@arm.com; Dharmik Thakkar
> <dharmik.thakkar@arm.com>
> Subject: [PATCH v2 2/5] app/testpmd: print fractional part in CPU cycles
> 
> Change printing of CPU cycles/packet to include fractional part for
> accurateness.
> 
> Example:
> 
> Without patch:
> CPU cycles/packet=14
> (total cycles=4899533541 / total RX packets=343031966)
> 
> With patch:
> CPU cycles/packet=14.28
> (total cycles=4899533541 / total RX packets=343031966)
> 
> Signed-off-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Reviewed-by: Phil Yang <phil.yang@arm.com>

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 806abb805879..a7ac6c66ce1c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1955,10 +1955,10 @@  fwd_stats_display(void)
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
 #define CYC_PER_MHZ 1E6
 	if (total_recv > 0)
-		printf("\n  CPU cycles/packet=%u (total cycles="
+		printf("\n  CPU cycles/packet=%.2F (total cycles="
 		       "%"PRIu64" / total RX packets=%"PRIu64") at %"PRIu64
 		       " MHz Clock\n",
-		       (unsigned int)(fwd_cycles / total_recv),
+		       (double) fwd_cycles / total_recv,
 		       fwd_cycles, total_recv,
 		       (uint64_t)(rte_get_tsc_hz() / CYC_PER_MHZ));
 #endif