コード例 #1
0
            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)
コード例 #2
0
        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)
コード例 #3
0
    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)
コード例 #4
0
    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)
コード例 #5
0
 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)
コード例 #6
0
 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)