Skip to content

Commit

Permalink
add chain parameter to perf command tooD
Browse files Browse the repository at this point in the history
  • Loading branch information
enthusiastmartin committed Mar 22, 2022
1 parent f564dfc commit cd885a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bench_wizard/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1"
__version__ = "0.5.2"
12 changes: 10 additions & 2 deletions bench_wizard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,26 @@ 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):
print(f"{reference_values} does not exist", file=sys.stderr)
exit(1)

config = PerformanceConfig(
reference_values=reference_values,
pallets=pallet,
reference_values=reference_values, pallets=pallet, chain=chain
)

try:
Expand Down
15 changes: 11 additions & 4 deletions bench_wizard/performance.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bench-wizard"
version = "0.5.1"
version = "0.5.2"
description = ""
authors = ["Martin Hloska <[email protected]>"]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_bench_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "0.5.0"
assert __version__ == "0.5.2"

0 comments on commit cd885a1

Please sign in to comment.