From ea234d9e73e4e624173d65a2b409a965c4fa90f3 Mon Sep 17 00:00:00 2001 From: jist <95856749+george0st@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:49:56 +0200 Subject: [PATCH 1/3] Update version.py --- qgate_perf/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qgate_perf/version.py b/qgate_perf/version.py index 271f680..d85b45e 100644 --- a/qgate_perf/version.py +++ b/qgate_perf/version.py @@ -1,3 +1,3 @@ # Store the version here so: -__version__ = '0.4.26' \ No newline at end of file +__version__ = '0.4.27' \ No newline at end of file From e828d9975e8950540ffc4ad13341838865c94155 Mon Sep 17 00:00:00 2001 From: jist <95856749+george0st@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:56:56 +0200 Subject: [PATCH 2/3] Update parallel_executor.py --- qgate_perf/parallel_executor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qgate_perf/parallel_executor.py b/qgate_perf/parallel_executor.py index 46c442f..bafa418 100644 --- a/qgate_perf/parallel_executor.py +++ b/qgate_perf/parallel_executor.py @@ -293,7 +293,7 @@ def run_bulk_executor(self, run_setup: RunSetup = None, sleep_between_bulks = 0, return_performance = False): - """ Run cykle of bulks in cycle of sequences for function execution + """ Run cycle of bulks in cycle of sequences for function execution :param bulk_list: list of bulks for execution in format [[rows, columns], ...] :param executor_list: list of executors for execution in format [[processes, threads, 'label'], ...] @@ -413,7 +413,7 @@ def run(self, processes = 2, threads = 2, run_setup: RunSetup = None, return_per self.init_run(run_setup) if self._output_file is not None: - file=self._open_output() + file = self._open_output() self._print_header(file, run_setup) @@ -503,7 +503,7 @@ def test_run(self, run_setup: RunSetup=None, print_output=False) -> bool: # init key="test-no-parallel" - dictionary={key: ""} + dictionary = {key: ""} run_return = RunReturn(key, dictionary) if not run_setup: @@ -523,7 +523,7 @@ def test_run(self, run_setup: RunSetup=None, print_output=False) -> bool: return True @staticmethod - def create_graph_static(input_file, output_graph_dir="output", scope: GraphScope = GraphScope.all, picture_dpi=100, suppress_error = False) -> list[str]: + def create_graph_static(input_file, output_graph_dir = "output", scope: GraphScope = GraphScope.all, picture_dpi = 100, suppress_error = False) -> list[str]: """ Generate graph(s) based on output from performance tests @@ -552,7 +552,7 @@ def create_graph_static(input_file, output_graph_dir="output", scope: GraphScope return output_file - def create_graph(self, output_graph_dir="output", scope: GraphScope = GraphScope.all, picture_dpi=100, suppress_error = False) -> list[str]: + def create_graph(self, output_graph_dir = "output", scope: GraphScope = GraphScope.all, picture_dpi = 100, suppress_error = False) -> list[str]: """ Generate graph(s) based on output from performance tests. The outputs will be in subdirectories 'graph-perf' and 'graph-exec'. @@ -569,7 +569,7 @@ def create_graph(self, output_graph_dir="output", scope: GraphScope = GraphScope picture_dpi, suppress_error) - def create_graph_perf(self, output_graph_dir="output", picture_dpi=100, suppress_error = False) -> list[str]: + def create_graph_perf(self, output_graph_dir = "output", picture_dpi = 100, suppress_error = False) -> list[str]: """ Generate performance graph(s) based on output from performance tests. The outputs will be in subdirectory 'graph-perf'. @@ -585,7 +585,7 @@ def create_graph_perf(self, output_graph_dir="output", picture_dpi=100, suppress picture_dpi, suppress_error) - def create_graph_exec(self, output_graph_dir="output", picture_dpi=100, suppress_error = False) -> list[str]: + def create_graph_exec(self, output_graph_dir = "output", picture_dpi = 100, suppress_error = False) -> list[str]: """ Generate executors graph(s) based on output from performance tests. The outputs will be in subdirectory 'graph-exec'. From b4d5a8243f941987ef22cca189c424439b1fa4a2 Mon Sep 17 00:00:00 2001 From: jist <95856749+george0st@users.noreply.github.com> Date: Fri, 4 Oct 2024 16:17:04 +0200 Subject: [PATCH 3/3] Add documentation --- qgate_perf/output_performance.py | 2 ++ qgate_perf/output_setup.py | 3 +-- qgate_perf/parallel_executor.py | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qgate_perf/output_performance.py b/qgate_perf/output_performance.py index fe2ae47..96a9692 100644 --- a/qgate_perf/output_performance.py +++ b/qgate_perf/output_performance.py @@ -1,5 +1,7 @@ class OutputPerformance: + """Outputs from performance tests""" + def __init__(self, row, col, process, thread, calls_sec): self.bundle_row = row diff --git a/qgate_perf/output_setup.py b/qgate_perf/output_setup.py index 75d0879..66e1ea3 100644 --- a/qgate_perf/output_setup.py +++ b/qgate_perf/output_setup.py @@ -1,5 +1,3 @@ -import datetime - class Singleton (type): _instances = {} @@ -9,6 +7,7 @@ def __call__(cls, *args, **kwargs): return cls._instances[cls] class OutputSetup(metaclass=Singleton): + """Global setup/setting for tuning of output""" HUMAN_PRECISION = 4 HUMAN_JSON_SEPARATOR = (', ', ':') diff --git a/qgate_perf/parallel_executor.py b/qgate_perf/parallel_executor.py index bafa418..fee4a2f 100644 --- a/qgate_perf/parallel_executor.py +++ b/qgate_perf/parallel_executor.py @@ -1,10 +1,10 @@ import concurrent.futures import multiprocessing import os.path -import datetime -import time import json import gc +from datetime import datetime +from time import sleep from qgate_perf.file_format import FileFormat from qgate_perf.run_setup import RunSetup from qgate_perf.bundle_helper import BundleHelper @@ -89,7 +89,7 @@ def _print(self, file, out: str, readable_out: str = None): print(readable_out if readable_out else out) def _print_header(self, file, run_setup: RunSetup=None): - self._start_tasks = datetime.datetime.utcnow() + self._start_tasks = datetime.utcnow() self._print(file, f"############### {self._start_tasks.isoformat(' ')} ###############") total, free = self._memory() out = { @@ -137,7 +137,7 @@ def _host(self): return host def _print_footer(self, file, final_state): - seconds = round((datetime.datetime.utcnow() - self._start_tasks).total_seconds(), 1) + seconds = round((datetime.utcnow() - self._start_tasks).total_seconds(), 1) self._print(file, f"############### State: {'OK' if final_state else 'Error'}, " f" Duration: {self._readable_duration(seconds)} ({seconds}" @@ -227,7 +227,7 @@ def _print_detail(self, file, run_setup: RunSetup, return_dict, processes, threa FileFormat.PRF_CORE_TOTAL_CALL_PER_SEC: total_call_per_sec, # ok FileFormat.PRF_CORE_AVRG_TIME: 0 if executors == 0 else sum_avrg_time / executors, # ok FileFormat.PRF_CORE_STD_DEVIATION: 0 if executors == 0 else sum_deviation / executors, # ok - FileFormat.PRF_CORE_TIME_END: datetime.datetime.utcnow().isoformat(' ') + FileFormat.PRF_CORE_TIME_END: datetime.utcnow().isoformat(' ') } readable_out = { FileFormat.HM_PRF_CORE_PLAN_EXECUTOR_ALL: f"{processes * threads} [{processes},{threads}]", @@ -311,7 +311,7 @@ def run_bulk_executor(self, # sleep before other bulk count += 1 if count>1: - time.sleep(sleep_between_bulks) + sleep(sleep_between_bulks) # execute run_setup.set_bulk(bulk[0], bulk[1])