summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-06-05 13:19:54 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-06-05 13:19:54 +0300
commit5216c6a22a2324bf555b590b34594a63d8aeeb7d (patch)
treee72a673bf611350cfadb5b6776e259367e1f7ff7 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
parent9b8f4554f63056ef214053b41ec31c3d3a75125b (diff)
cpu utilization Python get_stats replace "force" flag with "use_1sec_cache", default False.
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index 132d34ee..d23dd33f 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -421,7 +421,7 @@ class CTRexInfoGenerator(object):
return {"latency_histogram": ExportableStats(None, stats_table)}
def _generate_cpu_util_stats(self):
- util_stats = self._util_stats_ref.get_stats()
+ util_stats = self._util_stats_ref.get_stats(use_1sec_cache = True)
if not util_stats or 'cpu' not in util_stats:
raise Exception("Excepting 'cpu' section in stats %s" % util_stats)
cpu_stats = util_stats['cpu']
@@ -439,7 +439,7 @@ class CTRexInfoGenerator(object):
return {'cpu_util(%)': ExportableStats(None, stats_table)}
def _generate_mbuf_util_stats(self):
- util_stats = self._util_stats_ref.get_stats()
+ util_stats = self._util_stats_ref.get_stats(use_1sec_cache = True)
if not util_stats or 'mbuf_stats' not in util_stats:
raise Exception("Excepting 'mbuf_stats' section in stats %s" % util_stats)
mbuf_stats = util_stats['mbuf_stats']
@@ -1358,9 +1358,9 @@ class CUtilStats(CTRexStats):
self.history = deque(maxlen = 1)
self.mbuf_types_list = None
- def get_stats(self, force = False):
+ def get_stats(self, use_1sec_cache = False):
time_now = time.time()
- if self.last_update_ts + 1 < time_now or not self.history or force:
+ if self.last_update_ts + 1 < time_now or not self.history or not use_1sec_cache:
rc = self.client._transmit('get_utilization')
if not rc:
raise Exception(rc)