diff --git a/bench_wizard/__version__.py b/bench_wizard/__version__.py index dd9b22c..7225152 100644 --- a/bench_wizard/__version__.py +++ b/bench_wizard/__version__.py @@ -1 +1 @@ -__version__ = "0.5.1" +__version__ = "0.5.2" diff --git a/bench_wizard/main.py b/bench_wizard/main.py index 362e024..d5f53a7 100644 --- a/bench_wizard/main.py +++ b/bench_wizard/main.py @@ -95,9 +95,18 @@ def benchmark( required=True, help="Pallets", ) +@click.option( + "-c", + "--chain", + type=str, + required=False, + default="dev", + help="chain", +) def pc( reference_values: str, pallet: list, + chain: str, ): if not os.path.isfile(reference_values): @@ -105,8 +114,7 @@ def pc( exit(1) config = PerformanceConfig( - reference_values=reference_values, - pallets=pallet, + reference_values=reference_values, pallets=pallet, chain=chain ) try: diff --git a/bench_wizard/performance.py b/bench_wizard/performance.py index 11fc37a..78c8d9f 100644 --- a/bench_wizard/performance.py +++ b/bench_wizard/performance.py @@ -1,7 +1,7 @@ import json import subprocess from dataclasses import dataclass -from typing import List +from typing import List, Optional from bench_wizard.benchmark import Benchmark from bench_wizard.cargo import Cargo @@ -18,10 +18,13 @@ class PerformanceConfig: pallets: [str] reference_values: str + chain: Optional[str] = "dev" class PalletPerformance: - def __init__(self, pallet: str, ref_value: float, extrinsics: list): + def __init__( + self, pallet: str, ref_value: float, extrinsics: list, chain: str = "dev" + ): self._pallet = pallet self._stdout = None self._ref_value = ref_value @@ -38,6 +41,8 @@ def __init__(self, pallet: str, ref_value: float, extrinsics: list): self._is_error = False self._error_reason = False + self._chain = chain + @property def pallet(self): return self._pallet @@ -61,7 +66,7 @@ def raw(self) -> bytes: def run(self, rerun: bool = False) -> None: """Run benchmark and parse the result""" - cargo = Cargo(pallet=self.pallet) + cargo = Cargo(pallet=self.pallet, chain=self._chain) benchmark = Benchmark(self.pallet, cargo.command()) benchmark.run() @@ -113,7 +118,9 @@ def _prepare_benchmarks( for pallet in config.pallets: ref_data = reference_values[pallet] ref_value = sum(list(map(lambda x: float(x), ref_data.values()))) - benchmarks.append(PalletPerformance(pallet, ref_value, ref_data.keys())) + benchmarks.append( + PalletPerformance(pallet, ref_value, ref_data.keys(), chain=config.chain) + ) return benchmarks diff --git a/pyproject.toml b/pyproject.toml index b1a8a03..82ebcfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bench-wizard" -version = "0.5.1" +version = "0.5.2" description = "" authors = ["Martin Hloska "] diff --git a/tests/test_bench_wizard.py b/tests/test_bench_wizard.py index 34133df..fc3ddbb 100644 --- a/tests/test_bench_wizard.py +++ b/tests/test_bench_wizard.py @@ -2,4 +2,4 @@ def test_version(): - assert __version__ == "0.5.0" + assert __version__ == "0.5.2"