From: Ondrej Lichtner olichtne@redhat.com
This adds two new functions that work as templates when working with Netperf and PerfRepo.
netperf_baseline_template takes a TestModule (Netperf) and a PerfRepoBaseline object to set the threshold options of the Netperf module based on data available from the Baseline.
netperf_result_template takes a PerfRepoResult object and result data returned by a netperf client to add values to the PerfRepoResult object.
These templates are based on how we work with PerfRepo and Netperf so they might not be useful for everyone.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/PerfRepoUtils.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/lnst/Controller/PerfRepoUtils.py b/lnst/Controller/PerfRepoUtils.py index 4d30110..c5df2e0 100644 --- a/lnst/Controller/PerfRepoUtils.py +++ b/lnst/Controller/PerfRepoUtils.py @@ -11,3 +11,38 @@ __author__ = """ olichtne@redhat.com (Ondrej Lichtner) """
+import logging +from lnst.Common.Utils import Noop + +def netperf_baseline_template(module, baseline): + if baseline.get_texec() is None: + return module + + logging.debug("Setting Netperf threshold.") + throughput = baseline.get_value('throughput') + deviation = baseline.get_value('throughput_deviation') + if throughput is not None and deviation is not None: + module.update_options({'threshold': '%s bits/sec' % throughput, + 'threshold_deviation': '%s bits/sec' % deviation}) + return module + +def netperf_result_template(perfrepo_result, netperf_result): + if isinstance(perfrepo_result, Noop): + return perfrepo_result + + try: + result = netperf_result.get_result() + res_data = result['res_data'] + rate = res_data['rate'] + deviation = res_data['rate_deviation'] + except: + rate = 0.0 + deviation = 0.0 + + logging.debug("Adding Netperf results to PerfRepo object.") + perfrepo_result.add_value('throughput', rate) + perfrepo_result.add_value('throughput_min', rate - deviation) + perfrepo_result.add_value('throughput_max', rate + deviation) + perfrepo_result.add_value('throughput_deviation', deviation) + + return perfrepo_result