summaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/vcl/vcl_test.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-04-29 21:28:03 -0700
committerDave Barach <openvpp@barachs.net>2021-04-30 14:39:39 +0000
commit01fcd757a1ecbd555fb8a8c86238e128c894ad48 (patch)
tree01ef8c1875d3afb5b3fc21d073589e32f54e94b8 /src/plugins/hs_apps/vcl/vcl_test.h
parent1bb67abf3c6816b6f2c22eaeb1bdc355c4c95a46 (diff)
hsa: vcl test client incremental stats
Add option to print per second tx stats Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I7f226a6521da13ab29de65a441f73d4e56fb57cf
Diffstat (limited to 'src/plugins/hs_apps/vcl/vcl_test.h')
-rw-r--r--src/plugins/hs_apps/vcl/vcl_test.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/hs_apps/vcl/vcl_test.h b/src/plugins/hs_apps/vcl/vcl_test.h
index d475ec3c0a2..f1e6bc4eb6c 100644
--- a/src/plugins/hs_apps/vcl/vcl_test.h
+++ b/src/plugins/hs_apps/vcl/vcl_test.h
@@ -136,6 +136,7 @@ typedef struct vcl_test_session
char *rxbuf;
vcl_test_cfg_t cfg;
vcl_test_stats_t stats;
+ vcl_test_stats_t old_stats;
int session_index;
vppcom_endpt_t endpt;
uint8_t ip[16];
@@ -396,6 +397,37 @@ vcl_test_stats_dump (char *header, vcl_test_stats_t * stats,
printf (VCL_TEST_SEPARATOR_STRING);
}
+static inline double
+vcl_test_time_diff (struct timespec *old, struct timespec *new)
+{
+ uint64_t sec, nsec;
+ if ((new->tv_nsec - old->tv_nsec) < 0)
+ {
+ sec = new->tv_sec - old->tv_sec - 1;
+ nsec = new->tv_nsec - old->tv_nsec + 1e9;
+ }
+ else
+ {
+ sec = new->tv_sec - old->tv_sec;
+ nsec = new->tv_nsec - old->tv_nsec;
+ }
+ return (double) sec + (1e-9 * nsec);
+}
+
+static inline void
+vcl_test_stats_dump_inc (vcl_test_stats_t *old, vcl_test_stats_t *new)
+{
+ double duration, rate;
+ uint64_t total_bytes;
+
+ duration = vcl_test_time_diff (&old->stop, &new->stop);
+
+ total_bytes = new->tx_bytes - old->tx_bytes;
+ rate = (double) total_bytes * 8 / duration / 1e9;
+ printf ("Sent %lu Mbytes in %.2lf seconds %.2lf Gbps\n",
+ (uint64_t) (total_bytes / 1e6), duration, rate);
+}
+
static inline int
vcl_comp_tspec (struct timespec *a, struct timespec *b)
{