From 5a4f95444d2a323b2ba7dba0eb7cbe513f080a93 Mon Sep 17 00:00:00 2001 From: David Naylor Date: Wed, 15 May 2019 11:36:35 -0700 Subject: [PATCH] fixup! core+proto: Generalize histogram utilities --- bessctl/conf/port/latency.bess | 20 +++++++++---------- bessctl/measurement_utils.py | 4 ++-- bessctl/module_tests/timestamp.py | 32 +++++++++++++++---------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/bessctl/conf/port/latency.bess b/bessctl/conf/port/latency.bess index 17de3c71e..1a7c11a34 100644 --- a/bessctl/conf/port/latency.bess +++ b/bessctl/conf/port/latency.bess @@ -69,13 +69,13 @@ while True: (ret.timestamp - start_time, diff_pkts / 1e6, diff_bits / 1e6, - ret.latency.avg_ns / 1e3, - ret.latency.min_ns / 1e3, - ret.latency.percentile_values_ns[0] / 1e3, - ret.latency.percentile_values_ns[1] / 1e3, - ret.latency.max_ns / 1e3, - ret.jitter.avg_ns / 1e3, - ret.jitter.min_ns / 1e3, - ret.jitter.percentile_values_ns[0] / 1e3, - ret.jitter.percentile_values_ns[1] / 1e3, - ret.jitter.max_ns / 1e3)) + ret.latency_ns.avg / 1e3, + ret.latency_ns.min / 1e3, + ret.latency_ns.percentile_values[0] / 1e3, + ret.latency_ns.percentile_values[1] / 1e3, + ret.latency_ns.max / 1e3, + ret.jitter_ns.avg / 1e3, + ret.jitter_ns.min / 1e3, + ret.jitter_ns.percentile_values[0] / 1e3, + ret.jitter_ns.percentile_values[1] / 1e3, + ret.jitter_ns.max / 1e3)) diff --git a/bessctl/measurement_utils.py b/bessctl/measurement_utils.py index 8ede7ad68..b82876c90 100644 --- a/bessctl/measurement_utils.py +++ b/bessctl/measurement_utils.py @@ -194,8 +194,8 @@ def next(self): rtt = dict() jitter = dict() for i, p in enumerate(self.rtt_percentiles): - rtt[p] = mstats.latency.percentile_values_ns[i] - jitter[p] = mstats.jitter.percentile_values_ns[i] + rtt[p] = mstats.latency_ns.percentile_values[i] + jitter[p] = mstats.jitter_ns.percentile_values[i] if self.rate: now = time.time() diff --git a/bessctl/module_tests/timestamp.py b/bessctl/module_tests/timestamp.py index ad64b89a4..580714df2 100644 --- a/bessctl/module_tests/timestamp.py +++ b/bessctl/module_tests/timestamp.py @@ -60,28 +60,28 @@ def test_timestamped_and_measured(self): # timestamp: 1517529594.72 # packets: 64807616 # bits: 43550717952 - # latency = { + # latency_ns = { # count: 64807616 - # min_ns: 400 - # avg_ns: 513 - # max_ns: 295600 - # total_ns: 33273840000 - # percentile_values_ns: [400, 500, 500, 500, 295600] - # resolution_ns: 100 + # min: 400 + # avg: 513 + # max: 295600 + # total: 33273840000 + # percentile_values: [400, 500, 500, 500, 295600] + # resolution: 100 # } - # jitter = { + # jitter_ns = { # count: 3238279 - # avg_ns: 15 - # max_ns: 295100 - # total_ns: 48577800 - # resolution_ns: 100 + # avg: 15 + # max: 295100 + # total: 48577800 + # resolution: 100 # } print() - print('min ns =', stats.latency.min_ns) - print('avg ns =', stats.latency.avg_ns) + print('min ns =', stats.latency_ns.min) + print('avg ns =', stats.latency_ns.avg) # these two should be approximately equal - within about 1% - a = stats.latency.avg_ns * stats.latency.count - b = stats.latency.total_ns + a = stats.latency_ns.avg * stats.latency_ns.count + b = stats.latency_ns.total diff = abs(a - b) / float(b) * 100.0 self.assertLessEqual(diff, 1.0)