Skip to content

Commit

Permalink
Merge pull request #49 from george0st/changes
Browse files Browse the repository at this point in the history
Add return performance to the Run
  • Loading branch information
george0st authored Oct 3, 2024
2 parents a884167 + 8c8495f commit 079e043
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
36 changes: 27 additions & 9 deletions qgate_perf/parallel_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,19 @@ def run_executor(self, executor_list = ExecutorHelper.PROCESS_2_8_THREAD_1_4_SHO
return final_state, performance
return final_state

def run(self, processes=2, threads=2, run_setup: RunSetup=None) -> bool:
def run(self, processes = 2, threads = 2, run_setup: RunSetup = None, return_performance = False):
""" Run execution of parallel call
:param processes: how much processes will be used
:param threads: how much threads will be used
:param run_setup: setup of execution
:param return_performance: add to the return also performance, return will be state and performance (default is False)
:return: return state, True - all executions was without exceptions,
False - some exceptions
"""
file = None
final_state=True
performance = []
print('Execution...')

try:
Expand All @@ -466,7 +468,13 @@ def run(self, processes=2, threads=2, run_setup: RunSetup=None) -> bool:
with multiprocessing.Manager() as manager:
return_dict = manager.dict()
self._executeCore(run_setup, return_dict, processes, threads)
self._print_detail(file, run_setup, return_dict, processes, threads)
cals_sec = self._print_detail(file, run_setup, return_dict, processes, threads)
if return_performance:
performance.append(OutputPerformance(run_setup.bulk_row,
run_setup.bulk_col,
processes,
threads,
cals_sec))
if not self._final_state(return_dict):
final_state = False

Expand All @@ -478,30 +486,40 @@ def run(self, processes=2, threads=2, run_setup: RunSetup=None) -> bool:
finally:
if file is not None:
file.close()

if return_performance:
return final_state, performance
return final_state

def one_run(self, run_setup: RunSetup=None) -> bool:
""" Run test, only one call, execution in new process, with standart write outputs
def one_run(self, run_setup: RunSetup = None, return_performance = False):
""" Run test, only one call, execution in new process, with standard write outputs
:param run_setup: setting for run
:param parameters: parameters for execution, application in case the run_setup is None
:param return_performance: add to the return also performance, return will be state and performance (default is False)
:return: return state, True - all executions was without exceptions,
False - some exceptions
"""

# setup minimalistic values
if not run_setup:
run_setup = RunSetup(duration_second=0, start_delay=0)
run_setup = RunSetup(duration_second = 0, start_delay = 0)
run_setup.set_bulk(1,1)

# run
return self.run(processes=1,
threads=1,
run_setup=run_setup)
if return_performance:
state, perf = self.run(processes = 1,
threads = 1,
run_setup = run_setup,
return_performance = return_performance)
return state, perf
return self.run(processes = 1,
threads = 1,
run_setup = run_setup)

def init_run(self, run_setup: RunSetup=None, print_output=False) -> bool:
""" Init call in current process/thread (without ability to define parallel execution and without
write standard outputs to file). One new parametr was added '__INIT__': True
write standard outputs to file). One new parameter was added '__INIT__': True
:param parameters: parameters for execution, application in case the run_setup is None
:return: return state, True - execution was without exception,
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.25'
__version__ = '0.4.26'
4 changes: 2 additions & 2 deletions tests/test_core_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def prf_calibration_onehundred_ms(run_setup: RunSetup) -> ParallelProbe:
class TestCaseCoreEvaluation(unittest.TestCase):
"""
Test, if calculation of performance is correct
IMPORTANT (main ideas)
- all cases will have similar calls per second
- the different duration time of tests does not change performance (calls per second)
Expand All @@ -53,7 +53,7 @@ class TestCaseCoreEvaluation(unittest.TestCase):

@classmethod
def setUpClass(cls):
shutil.rmtree(TestCaseCoreEvaluationCheck.OUTPUT_ADR, True)
shutil.rmtree(TestCaseCoreEvaluation.OUTPUT_ADR, True)

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit 079e043

Please sign in to comment.