def test_calculate_delay_per_req(): num_total_requests = 2231 total_expected_execution_time = 60 delay_per_req = delay.calculate_delay_per_req( num_total_requests, total_expected_execution_time) assert delay_per_req == 0.027
def _calculate_delays(load_size: int): """ Figure out how long master should run for and how long delays should be between requests """ total_expected_execution_time = calculate_total_expected_execution_time( load_size) delay_per_req = calculate_delay_per_req(load_size, total_expected_execution_time) return delay_per_req
def test_calculate_delay_between_workers_random(): load = [1] * 1234 load_chunks, load_size = master._generate_chunked_load(load=load, chunk_max=100) delay_per_req = delay.calculate_delay_per_req( num_total_requests=len(load), total_expected_execution_time=65) delays = delay.calculate_delays_between_workers(load_chunks, delay_per_req) delays_rand = delay.make_delays_random(delays) assert delays[0] != delays_rand[0] and len(delays) == len(delays_rand)
def test_calculate_delay_between_slaves(): load = [1] * 1234 load_chunks, load_size = master._generate_chunked_load(load=load, chunk_max=100) delay_per_req = delay.calculate_delay_per_req( num_total_requests=len(load), total_expected_execution_time=65) delays = delay.calculate_delays_between_slaves(load_chunks, delay_per_req) from pprint import pprint pprint(load_chunks) pprint(delays) print(sum(delays)) assert int(sum(delays)) == 65