async def chunk_of_work(): # Make a request to dummy backend io_duration = next(parameters.io_duration_seq) url = f'{next(self.backend_addresses)}/simulate-backend' params = { 'duration': str(io_duration), 'response_type': parameters.io_traffic } await session.get(url, params=params) # Simulate CPU work cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds)
def chunk_of_work(): # Make a request to dummy backend io_duration = next(parameters.io_duration_seq) params = { 'duration': str(io_duration), 'response_type': parameters.io_traffic } base_url = '{}/simulate-backend'.format( next(self.backend_addresses)) url = httputil.url_concat(base_url, params) yield async_client.fetch(url) # Simulate CPU work cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds)
async def sequential_io(self, request): parameters = Parameters(request) async with aiohttp.ClientSession() as session: for _ in range(parameters.io_number): # Make a request to dummy backend io_duration = next(parameters.io_duration_seq) url = f'{next(self.backend_addresses)}/simulate-backend' params = { 'duration': str(io_duration), 'response_type': parameters.io_traffic } await session.get(url, params=params) # Simulate CPU work cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds) body = parameters.response_content return web.Response(body=body)
def get(self): parameters = Parameters(self) async_client = httpclient.AsyncHTTPClient() for _ in range(parameters.io_number): # Make a request to dummy backend io_duration = next(parameters.io_duration_seq) params = { 'duration': str(io_duration), 'response_type': parameters.io_traffic } base_url = '{}/simulate-backend'.format( next(self.backend_addresses)) url = httputil.url_concat(base_url, params) yield async_client.fetch(url) # Simulate CPU work cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds) body = parameters.response_content self.write(body)
def get(self): parameters = Parameters(self) cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds) body = parameters.response_content self.write(body)
async def no_io(request): parameters = Parameters(request) cpu_seconds = next(parameters.cpu_load_seq) shared.load_cpu(cpu_seconds) body = parameters.response_content return web.Response(body=body)