X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fbenchmark%2Frunners%2Farithmetic.py;h=65fdb9d669d2eb42ed2672eb7fa93e624718d0fe;hb=5e3c9075dcc12619a97b9e99b26532c5576fc6ca;hp=74a236f44b92763805319188ca55c46e3249e086;hpb=3be4620ca48858e8a0cb38b61b6c5bbb45f96472;p=yardstick.git diff --git a/yardstick/benchmark/runners/arithmetic.py b/yardstick/benchmark/runners/arithmetic.py index 74a236f44..65fdb9d66 100755 --- a/yardstick/benchmark/runners/arithmetic.py +++ b/yardstick/benchmark/runners/arithmetic.py @@ -16,20 +16,25 @@ # yardstick comment: this is a modified copy of # rally/rally/benchmark/runners/constant.py -'''A runner that every run arithmetically steps specified input value(s) to +"""A runner that every run arithmetically steps specified input value(s) to the scenario. This just means step value(s) is added to the previous value(s). It is possible to combine several named input values and run with those either as nested for loops or combine each i:th index of each "input value list" until the end of the shortest list is reached (optimally all lists should be defined with the same number of values when using such iter_type). -''' +""" -import os -import multiprocessing +from __future__ import absolute_import + +import itertools import logging -import traceback +import multiprocessing +import os import time -import itertools +import traceback + +import six +from six.moves import range from yardstick.benchmark.runners import base @@ -71,8 +76,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg, return -1 if start > stop else 1 param_iters = \ - [xrange(d['start'], d['stop'] + margin(d['start'], d['stop']), - d['step']) for d in runner_cfg['iterators']] + [range(d['start'], d['stop'] + margin(d['start'], d['stop']), + d['step']) for d in runner_cfg['iterators']] param_names = [d['name'] for d in runner_cfg['iterators']] iter_type = runner_cfg.get("iter_type", "nested_for_loops") @@ -82,10 +87,10 @@ def _worker_process(queue, cls, method_name, scenario_cfg, loop_iter = itertools.product(*param_iters) elif iter_type == 'tuple_loops': # Combine each i;th index of respective parameter list - loop_iter = itertools.izip(*param_iters) + loop_iter = six.moves.zip(*param_iters) else: LOG.warning("iter_type unrecognized: %s", iter_type) - raise + raise TypeError("iter_type unrecognized: %s", iter_type) # Populate options and run the requested method for each value combination for comb_values in loop_iter: @@ -93,7 +98,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg, if aborted.is_set(): break - LOG.debug("runner=%(runner)s seq=%(sequence)s START" % + LOG.debug("runner=%(runner)s seq=%(sequence)s START", {"runner": runner_cfg["runner_id"], "sequence": sequence}) for i, value in enumerate(comb_values): @@ -109,7 +114,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg, if sla_action == "assert": raise elif sla_action == "monitor": - LOG.warning("SLA validation failed: %s" % assertion.args) + LOG.warning("SLA validation failed: %s", assertion.args) errors = assertion.args except Exception as e: errors = traceback.format_exc() @@ -129,12 +134,12 @@ def _worker_process(queue, cls, method_name, scenario_cfg, queue.put(record) - LOG.debug("runner=%(runner)s seq=%(sequence)s END" % + LOG.debug("runner=%(runner)s seq=%(sequence)s END", {"runner": runner_cfg["runner_id"], "sequence": sequence}) sequence += 1 - if (errors and sla_action is None): + if errors and sla_action is None: break benchmark.teardown() @@ -142,7 +147,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg, class ArithmeticRunner(base.Runner): - '''Run a scenario arithmetically stepping input value(s) + """Run a scenario arithmetically stepping input value(s) Parameters interval - time to wait between each scenario invocation @@ -175,7 +180,7 @@ class ArithmeticRunner(base.Runner): default: none - name - and so on...... - ''' + """ __execution_type__ = 'Arithmetic'