From 0fc30adae2fc5708baef74d36e97a174b078f332 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 7 Dec 2015 09:08:02 -0500 Subject: added 'dry' option to start command this enables showing a profile map before starting --- .../trex_control_plane/common/text_opts.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'scripts/automation/trex_control_plane/common') diff --git a/scripts/automation/trex_control_plane/common/text_opts.py b/scripts/automation/trex_control_plane/common/text_opts.py index 69c76674..5a86149c 100755 --- a/scripts/automation/trex_control_plane/common/text_opts.py +++ b/scripts/automation/trex_control_plane/common/text_opts.py @@ -27,6 +27,39 @@ def format_num (size, suffix = ""): return "NaN" +def format_time (t_sec): + if t_sec < 0: + return "infinite" + + if t_sec < 1: + # low numbers + for unit in ['ms', 'usec', 'ns']: + t_sec *= 1000.0 + if t_sec >= 1.0: + return '{:,.2f} [{:}]'.format(t_sec, unit) + + return "NaN" + + else: + # seconds + if t_sec < 60.0: + return '{:,.2f} [{:}]'.format(t_sec, 'sec') + + # minutes + t_sec /= 60.0 + if t_sec < 60.0: + return '{:,.2f} [{:}]'.format(t_sec, 'minutes') + + # hours + t_sec /= 60.0 + if t_sec < 24.0: + return '{:,.2f} [{:}]'.format(t_sec, 'hours') + + # days + t_sec /= 24.0 + return '{:,.2f} [{:}]'.format(t_sec, 'days') + + def format_percentage (size): return "%0.2f %%" % (size) -- cgit 1.2.3-korg