diff options
author | Yiting.Li <liyiting@huawei.com> | 2015-12-22 17:11:12 -0800 |
---|---|---|
committer | Yiting.Li <liyiting@huawei.com> | 2015-12-22 17:11:12 -0800 |
commit | 8f1101df131a4d3e03b377738507d88b745831c0 (patch) | |
tree | 73f140474fcec2a77c85a453f6946957ca0742d1 /vstf/vstf/agent/equalizer/optimize.py | |
parent | 1a24ebbda3f95600c0e7d5ed8661317a8ff7e265 (diff) |
Upload the contribution of vstf as bottleneck network framework.
End to End Performance test
JIRA:BOTTLENECK-29
Change-Id: Ib2c553c8b60d6cda9e7a7b52b737c9139f706ebd
Signed-off-by: Yiting.Li <liyiting@huawei.com>
Diffstat (limited to 'vstf/vstf/agent/equalizer/optimize.py')
-rwxr-xr-x | vstf/vstf/agent/equalizer/optimize.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vstf/vstf/agent/equalizer/optimize.py b/vstf/vstf/agent/equalizer/optimize.py new file mode 100755 index 00000000..941769a3 --- /dev/null +++ b/vstf/vstf/agent/equalizer/optimize.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +import commands +import re + + +# import pdb +# pdb.set_trace() + +class Optimize(object): + def __init__(self): + pass + + def bind_cpu(self, cpu_range, thread): + flag, num = commands.getstatusoutput('taskset -pc %s %s' % (cpu_range, thread)) + return flag + + def catch_thread_info(self): + thread_info = {'fwd_vhost': None, 'src_recv_irq': None, 'dst_send_irq': None} + # top -H get the usage info + flag, threads_usages = commands.getstatusoutput('top -bH -n1 -c -w 2000') + line_array = threads_usages.split('\n') + # get highest vhost line + for line in line_array: + if re.search('vhost-', line) and self._check_thread_usage(line): + thread_info['fwd_vhost'] = line.split()[0] + break + # get highest irq thread as src_recv_irq thread + for line in line_array: + if re.search('irq/', line) and self._check_thread_usage(line): + thread_info['src_recv_irq'] = line.split()[0] + line_array.remove(line) + break + # get the second highest irq thread as dst_send_irq + for line in line_array: + if re.search('irq/', line) and self._check_thread_usage(line): + thread_info['dst_send_irq'] = line.split()[0] + break + # check the data valid + + for key in thread_info.keys(): + if thread_info[key] is None: + return False, str(thread_info) + return True, str(thread_info) + + def _check_thread_usage(self, line): + try: + usage = line.split()[8] + if float(usage) >= 3.0: + return True + else: + print("[ERROR]The highest thread %s is less than 0.05" % usage) + return False + except: + print("[ERROR]The thread usage get failed.") |