def test_run_time(test_name: str, number_of_iterations: int, throw_result: bool=False): index = ResultExistence(True, copy.copy(number_of_iterations)) start_time = time.time() try: yield index except: raise finally: number_of_iterations -= index.result end_time = time.time() result_time = end_time - start_time print('>>> "{}"'.format(test_name)) print('\t' + 'It was used', result_time, 'seconds to process', number_of_iterations, 'iterations.') if result_time > 0: print('\t' + 'There is', number_of_iterations / result_time, 'iterations per second') print() if throw_result: result_data = list() result_data.append(result_time) if result_time > 0: result_data.append(number_of_iterations / result_time) else: result_data.append(None) result_data = tuple(result_data) raise PerformanceTestResult(result_data)
def __init__(self, external_data_full_size: ResultExistence = None): self._l = deque() self._real_size = 0 self._init_param__external_data_full_size = external_data_full_size # self._l_length = deque() self._data_full_size = 0 self._external_data_full_size = external_data_full_size or ResultExistence( False, 0)
def __init__(self): self.global__data_size_limit = ResultExistence(True, 2 * 1024**3) self.global_in__data_size_limit = ResultExistence(True, 512 * 1024**2) self.global_in__data_full_size = ResultExistence(True, 0) self.global_in__deletable_data_full_size = ResultExistence(True, 0) self.global_out__data_size_limit = ResultExistence(True, 512 * 1024**2) self.global_out__data_full_size = ResultExistence(True, 0) self.global_out__deletable_data_full_size = ResultExistence(True, 0)
def __init__(self, joiner=None, external_data_length: ResultExistence = None): self._init_param__joiner = joiner self._init_param__external_data_length = external_data_length self._joiner = none_or(joiner, b'') self._data = deque() self._data_length = 0 self._real_size = 0 self._external_data_length = external_data_length or ResultExistence( False, 0)
def profiler_result(profiler, print_result=False, output_file: ResultExistence = None): output_file = output_file or ResultExistence(None, None) try: yield profiler except: raise finally: if print_result: profiler.print_stats() if output_file.existence: if output_file.result: profiler.dump_stats(output_file.result) else: # TODO: сделать автоматическое имя из имени прогоняемого файла и случайного GUID raise NotImplemented()
def __init__(self, joiner=None, on_hold_limit=None, on_hold_data_size_limit=None, external_data_length: ResultExistence = None, external_deletable_data_full_size: ResultExistence = None): super(DynamicListOfPiecesWithLengthControl, self).__init__(joiner, on_hold_limit) self._init_param__on_hold_data_size_limit = on_hold_data_size_limit self._init_param__external_data_length = external_data_length self._init_param__external_deletable_data_full_size = external_deletable_data_full_size self._on_hold_data_size_limit = on_hold_data_size_limit or 1024**2 self._deletable_data_full_size = 0 self._external_data_length = external_data_length or ResultExistence( False, 0) self._external_deletable_data_full_size = external_deletable_data_full_size or ResultExistence( False, 0)
def __init__(self, on_hold_limit=None, on_hold_data_size_limit=None, external_data_full_size: ResultExistence = None, external_deletable_data_full_size: ResultExistence = None): super(FIFOWithLengthControl, self).__init__(on_hold_limit) self._init_param__on_hold_data_size_limit = on_hold_data_size_limit self._init_param__external_data_full_size = external_data_full_size self._init_param__external_deletable_data_full_size = external_deletable_data_full_size self._l_length = list() # self._l_deletable_length = list() self._data_full_size = ResultCache() self._data_full_size.set(0) self._deletable_data_full_size = 0 self._on_hold_data_size_limit = on_hold_data_size_limit or 1024**2 * 10 self._external_data_full_size = external_data_full_size or ResultExistence( False, 0) self._external_deletable_data_full_size = external_deletable_data_full_size or ResultExistence( False, 0)