@@ -154,6 +154,7 @@ size_t sample_map_count[NUM_MAP];
154
154
enum log_level sample_log_level ;
155
155
struct sample_output sample_out ;
156
156
unsigned long sample_interval ;
157
+ __u64 sample_start_time ;
157
158
bool sample_err_exp ;
158
159
int sample_xdp_cnt ;
159
160
int sample_n_cpus ;
@@ -1339,23 +1340,26 @@ int __sample_init(int mask, int ifindex_from, int ifindex_to)
1339
1340
1340
1341
static void sample_summary_print (void )
1341
1342
{
1342
- double num = sample_out .rx_cnt .num ;
1343
+ __u64 start = sample_start_time ;
1344
+ __u64 now = gettime ();
1345
+ double dur_s = ((double )now - start ) / NANOSEC_PER_SEC ;
1343
1346
1347
+ print_always (" Duration : %.1fs\n" , dur_s );
1344
1348
if (sample_out .totals .rx ) {
1345
1349
double pkts = sample_out .totals .rx ;
1346
1350
1347
1351
print_always (" Packets received : %'-10" PRIu64 "\n" ,
1348
1352
(uint64_t )sample_out .totals .rx );
1349
1353
print_always (" Average packets/s : %'-10.0f\n" ,
1350
- round (pkts / num ));
1354
+ round (pkts / dur_s ));
1351
1355
}
1352
1356
if (sample_out .totals .redir ) {
1353
1357
double pkts = sample_out .totals .redir ;
1354
1358
1355
1359
print_always (" Packets redirected : %'-10" PRIu64 "\n" ,
1356
1360
sample_out .totals .redir );
1357
1361
print_always (" Average redir/s : %'-10.0f\n" ,
1358
- round (pkts / num ));
1362
+ round (pkts / dur_s ));
1359
1363
}
1360
1364
if (sample_out .totals .drop )
1361
1365
print_always (" Rx dropped : %'-10" PRIu64 "\n" ,
@@ -1372,7 +1376,7 @@ static void sample_summary_print(void)
1372
1376
print_always (" Packets transmitted : %'-10" PRIu64 "\n" ,
1373
1377
sample_out .totals .xmit );
1374
1378
print_always (" Average transmit/s : %'-10.0f\n" ,
1375
- round (pkts / num ));
1379
+ round (pkts / dur_s ));
1376
1380
}
1377
1381
}
1378
1382
@@ -1439,7 +1443,6 @@ static void sample_summary_update(struct sample_output *out)
1439
1443
sample_out .totals .drop_xmit += out -> totals .drop_xmit ;
1440
1444
sample_out .totals .err += out -> totals .err ;
1441
1445
sample_out .totals .xmit += out -> totals .xmit ;
1442
- sample_out .rx_cnt .num ++ ;
1443
1446
}
1444
1447
1445
1448
static void sample_stats_print (int mask , struct stats_record * cur ,
@@ -1585,6 +1588,8 @@ int sample_run(unsigned int interval, void (*post_cb)(void *), void *ctx)
1585
1588
if (!prev )
1586
1589
goto end_rec ;
1587
1590
1591
+ sample_start_time = gettime ();
1592
+
1588
1593
ret = sample_stats_collect (rec );
1589
1594
if (ret < 0 )
1590
1595
goto end_rec_prev ;
0 commit comments