Skip to content

Commit

Permalink
Merge pull request #52 from george0st/changes
Browse files Browse the repository at this point in the history
Tune documentation, increase version
  • Loading branch information
george0st authored Oct 4, 2024
2 parents 1726ceb + b4d5a82 commit b3d9a81
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions qgate_perf/output_performance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

class OutputPerformance:
"""Outputs from performance tests"""

def __init__(self, row, col, process, thread, calls_sec):

self.bundle_row = row
Expand Down
3 changes: 1 addition & 2 deletions qgate_perf/output_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import datetime


class Singleton (type):
_instances = {}
Expand All @@ -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 = (', ', ':')
Expand Down
26 changes: 13 additions & 13 deletions qgate_perf/parallel_executor.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}]",
Expand Down Expand Up @@ -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'], ...]
Expand All @@ -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])
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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'.
Expand All @@ -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'.
Expand All @@ -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'.
Expand Down
2 changes: 1 addition & 1 deletion qgate_perf/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Store the version here so:

__version__ = '0.4.26'
__version__ = '0.4.27'

0 comments on commit b3d9a81

Please sign in to comment.