On Fri, Oct 30, 2020 at 09:30:44AM +0100, Jan Tluka wrote:
It make more sense to have both BasePerfTestTweakMixin and
BasePerfTestIterationTweakMixin in one place.
In addition, the BasePerfTestTweakMixin was moved from BaseEnrtRecipe
to Perf.Recipe class.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
.../PerfTestMixins/BasePerfTestTweakMixin.py | 0
lnst/RecipeCommon/Perf/Recipe.py | 39 +++++++++++--------
lnst/Recipes/ENRT/BaseEnrtRecipe.py | 9 +----
.../SctpFirewallPerfTestMixin.py | 2 +-
lnst/Recipes/ENRT/PerfTestMixins/__init__.py | 1 -
5 files changed, 26 insertions(+), 25 deletions(-)
rename lnst/{Recipes/ENRT =>
RecipeCommon/Perf}/PerfTestMixins/BasePerfTestTweakMixin.py (100%)
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
b/lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
similarity index 100%
rename from lnst/Recipes/ENRT/PerfTestMixins/BasePerfTestTweakMixin.py
rename to lnst/RecipeCommon/Perf/PerfTestMixins/BasePerfTestTweakMixin.py
diff --git a/lnst/RecipeCommon/Perf/Recipe.py b/lnst/RecipeCommon/Perf/Recipe.py
index d48b956c..63ffa7f8 100644
--- a/lnst/RecipeCommon/Perf/Recipe.py
+++ b/lnst/RecipeCommon/Perf/Recipe.py
@@ -7,6 +7,7 @@ from lnst.RecipeCommon.Perf.Results import SequentialPerfResult
from lnst.RecipeCommon.Perf.Results import ParallelPerfResult
from lnst.RecipeCommon.Perf.PerfTestMixins import (
+ BasePerfTestTweakMixin,
BasePerfTestIterationTweakMixin,
)
@@ -53,25 +54,31 @@ class RecipeResults(object):
aggregated_results, new_results)
self._results[measurement] = aggregated_results
-class Recipe(BasePerfTestIterationTweakMixin, BaseRecipe):
+class Recipe(BasePerfTestTweakMixin, BasePerfTestIterationTweakMixin, BaseRecipe):
def perf_test(self, recipe_conf):
results = RecipeResults(recipe_conf)
- for i in range(recipe_conf.iterations):
- self.apply_perf_test_iteration_tweak(recipe_conf)
- self.describe_perf_test_iteration_tweak(recipe_conf)
-
- try:
- for measurement in recipe_conf.measurements:
- measurement.start()
- for measurement in reversed(recipe_conf.measurements):
- measurement.finish()
- for measurement in recipe_conf.measurements:
- measurement_results = measurement.collect_results()
- results.add_measurement_results(
- measurement, measurement_results)
- finally:
- self.remove_perf_test_iteration_tweak(recipe_conf)
+ self.apply_perf_test_tweak(recipe_conf)
+ self.describe_perf_test_tweak(recipe_conf)
+
+ try:
+ for i in range(recipe_conf.iterations):
Minor comment here, so only apply if there will be a v2.
I think at this point I would refactor this a bit due to "too many
levels of nesting" I think a new method for "one measurement iteration"
could help here and ensure that there's a single try-except-finally
block per method.
-Ondrej
+ self.apply_perf_test_iteration_tweak(recipe_conf)
+ self.describe_perf_test_iteration_tweak(recipe_conf)
+
+ try:
+ for measurement in recipe_conf.measurements:
+ measurement.start()
+ for measurement in reversed(recipe_conf.measurements):
+ measurement.finish()
+ for measurement in recipe_conf.measurements:
+ measurement_results = measurement.collect_results()
+ results.add_measurement_results(
+ measurement, measurement_results)
+ finally:
+ self.remove_perf_test_iteration_tweak(recipe_conf)
+ finally:
+ self.remove_perf_test_tweak(recipe_conf)
return results
diff --git a/lnst/Recipes/ENRT/BaseEnrtRecipe.py b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
index d629b726..180f922e 100644
--- a/lnst/Recipes/ENRT/BaseEnrtRecipe.py
+++ b/lnst/Recipes/ENRT/BaseEnrtRecipe.py
@@ -355,13 +355,8 @@ class BaseEnrtRecipe(CommonPerfTestTweakMixin,
methods to execute, report and evaluate the results.
"""
for perf_config in self.generate_perf_configurations(recipe_config):
- self.apply_perf_test_tweak(perf_config)
- self.describe_perf_test_tweak(perf_config)
- try:
- result = self.perf_test(perf_config)
- self.perf_report_and_evaluate(result)
- finally:
- self.remove_perf_test_tweak(perf_config)
+ result = self.perf_test(perf_config)
+ self.perf_report_and_evaluate(result)
def generate_ping_configurations(self, config):
"""Base ping test configuration generator
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
index c0520405..841df3f7 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/SctpFirewallPerfTestMixin.py
@@ -1,5 +1,5 @@
from lnst.Controller.RecipeResults import ResultLevel
-from lnst.Recipes.ENRT.PerfTestMixins import BasePerfTestTweakMixin
+from lnst.RecipeCommon.Perf.PerfTestMixins import BasePerfTestTweakMixin
class SctpFirewallPerfTestMixin(BasePerfTestTweakMixin):
def apply_perf_test_tweak(self, perf_config):
diff --git a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
index 8a109ad0..addfb641 100644
--- a/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
+++ b/lnst/Recipes/ENRT/PerfTestMixins/__init__.py
@@ -1,3 +1,2 @@
-from lnst.Recipes.ENRT.PerfTestMixins.BasePerfTestTweakMixin import
BasePerfTestTweakMixin
from lnst.Recipes.ENRT.PerfTestMixins.SctpFirewallPerfTestMixin import
SctpFirewallPerfTestMixin
from lnst.Recipes.ENRT.PerfTestMixins.CommonPerfTestTweakMixin import
CommonPerfTestTweakMixin
--
2.21.3
_______________________________________________
LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedora...