From 3e024d8bdcebdd3100851f28b5724a2ecbfc923a Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 17 May 2016 02:55:54 +0300 Subject: add latency panel to TUI --- .../stl/trex_stl_lib/utils/text_opts.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/text_opts.py') 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) -- cgit 1.2.3-korg