diff options
author | imarom <imarom@cisco.com> | 2015-12-07 09:08:02 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-12-07 09:09:59 -0500 |
commit | 0fc30adae2fc5708baef74d36e97a174b078f332 (patch) | |
tree | 74257f2c4ac243d387ca78d25210520d4d572e31 /scripts/automation/trex_control_plane/common | |
parent | 3c87156e57ba46fa725ed19bd33ca8b26afa25f7 (diff) |
added 'dry' option to start command
this enables showing a profile map before starting
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rwxr-xr-x | scripts/automation/trex_control_plane/common/text_opts.py | 33 |
1 files changed, 33 insertions, 0 deletions
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) |