summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-05-17 02:55:54 +0300
committerIdo Barnea <ibarnea@cisco.com>2016-05-18 19:23:47 +0300
commit3e024d8bdcebdd3100851f28b5724a2ecbfc923a (patch)
tree08c62dc02a86845f1d2ba643bd5fdb85860e79ce /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
parent9ba34d62a9faed8fb782062c58c3d746ce56a107 (diff)
add latency panel to TUI
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
index 7e0bf9e4..72be7c29 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py
@@ -36,11 +36,18 @@ def format_num (size, suffix = "", compact = True, opts = ()):
u = ''
if compact:
- for unit in ['','K','M','G','T','P']:
- if abs(size) < 1000.0:
- u = unit
- break
- size /= 1000.0
+ if 0 < abs(size) < 1:
+ for unit in ['m','u','n','p']:
+ size *= 1000
+ if abs(size) >= 1:
+ u = unit
+ break
+ else:
+ for unit in ['','K','M','G','T','P']:
+ if abs(size) < 1000.0:
+ u = unit
+ break
+ size /= 1000.0
if isinstance(size, float):
txt = "%3.2f" % (size)