summaryrefslogtreecommitdiffstats
path: root/src/main_dpdk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main_dpdk.cpp')
-rw-r--r--src/main_dpdk.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 440cf820..6dec3dec 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -2317,6 +2317,7 @@ public:
float m_open_flows;
float m_cpu_util;
float m_rx_cpu_util;
+ float m_bw_per_core;
uint8_t m_threads;
uint32_t m_num_of_ports;
@@ -2335,7 +2336,10 @@ private:
std::string CGlobalStats::get_field(std::string name,float &f){
char buff[200];
- snprintf(buff, sizeof(buff), "\"%s\":%.1f,",name.c_str(),f);
+ if(f <= -10.0 or f >= 10.0)
+ snprintf(buff, sizeof(buff), "\"%s\":%.1f,",name.c_str(),f);
+ else
+ snprintf(buff, sizeof(buff), "\"%s\":%.3e,",name.c_str(),f);
return (std::string(buff));
}
@@ -2347,7 +2351,10 @@ std::string CGlobalStats::get_field(std::string name,uint64_t &f){
std::string CGlobalStats::get_field_port(int port,std::string name,float &f){
char buff[200];
- snprintf(buff, sizeof(buff), "\"%s-%d\":%.1f,",name.c_str(),port,f);
+ if(f <= -10.0 or f >= 10.0)
+ snprintf(buff, sizeof(buff), "\"%s-%d\":%.1f,",name.c_str(),port,f);
+ else
+ snprintf(buff, sizeof(buff), "\"%s-%d\":%.3e,",name.c_str(),port,f);
return (std::string(buff));
}
@@ -2376,6 +2383,7 @@ void CGlobalStats::dump_json(std::string & json, bool baseline,uint32_t stats_ti
#define GET_FIELD_PORT(p,f) get_field_port(p,std::string(#f),lp->f)
json+=GET_FIELD(m_cpu_util);
+ json+=GET_FIELD(m_bw_per_core);
json+=GET_FIELD(m_rx_cpu_util);
json+=GET_FIELD(m_platform_factor);
json+=GET_FIELD(m_tx_bps);
@@ -2441,7 +2449,7 @@ void CGlobalStats::DumpAllPorts(FILE *fd){
- fprintf (fd," Cpu Utilization : %2.1f %% %2.1f Gb/core \n",m_cpu_util,(2*(m_tx_bps/1e9)*100.0/(m_cpu_util*m_threads)));
+ fprintf (fd," Cpu Utilization : %2.1f %% %2.1f Gb/core \n",m_cpu_util,m_bw_per_core);
fprintf (fd," Platform_factor : %2.1f \n",m_platform_factor);
fprintf (fd," Total-Tx : %s ",double_to_human_str(m_tx_bps,"bps",KBYE_1000).c_str());
if ( CGlobalInfo::is_learn_mode() ) {
@@ -3554,6 +3562,10 @@ void CGlobalTRex::get_stats(CGlobalStats & stats){
stats.m_tx_pps = total_tx_pps*pf;
stats.m_rx_pps = total_rx_pps*pf;
stats.m_tx_cps = m_last_total_cps*pf;
+ if(stats.m_cpu_util < 0.0001)
+ stats.m_bw_per_core = 0;
+ else
+ stats.m_bw_per_core = 2*(stats.m_tx_bps/1e9)*100.0/(stats.m_cpu_util*stats.m_threads);
stats.m_tx_expected_cps = m_expected_cps*pf;
stats.m_tx_expected_pps = m_expected_pps*pf;