MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ntb_calculate_throughput

Function ntb_calculate_throughput

dpdk/examples/ntb/ntb_fwd.c:793–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793static inline void
794ntb_calculate_throughput(uint16_t port) {
795 uint64_t diff_pkts_rx, diff_pkts_tx, diff_cycles;
796 uint64_t mpps_rx, mpps_tx;
797 static uint64_t prev_pkts_rx[2];
798 static uint64_t prev_pkts_tx[2];
799 static uint64_t prev_cycles[2];
800
801 diff_cycles = prev_cycles[port];
802 prev_cycles[port] = rte_rdtsc();
803 if (diff_cycles > 0)
804 diff_cycles = prev_cycles[port] - diff_cycles;
805 diff_pkts_rx = (ntb_port_stats[port].rx > prev_pkts_rx[port]) ?
806 (ntb_port_stats[port].rx - prev_pkts_rx[port]) : 0;
807 diff_pkts_tx = (ntb_port_stats[port].tx > prev_pkts_tx[port]) ?
808 (ntb_port_stats[port].tx - prev_pkts_tx[port]) : 0;
809 prev_pkts_rx[port] = ntb_port_stats[port].rx;
810 prev_pkts_tx[port] = ntb_port_stats[port].tx;
811 mpps_rx = diff_cycles > 0 ?
812 diff_pkts_rx * rte_get_tsc_hz() / diff_cycles : 0;
813 mpps_tx = diff_cycles > 0 ?
814 diff_pkts_tx * rte_get_tsc_hz() / diff_cycles : 0;
815 printf(" Throughput (since last show)\n");
816 printf(" Rx-pps: %12"PRIu64"\n Tx-pps: %12"PRIu64"\n",
817 mpps_rx, mpps_tx);
818
819}
820
821static void
822ntb_stats_display(void)

Callers 1

ntb_stats_displayFunction · 0.85

Calls 3

rte_get_tsc_hzFunction · 0.85
rte_rdtscFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected