14 """The Python AsyncIO Benchmark Clients."""
25 from src.proto.grpc.testing
import benchmark_service_pb2_grpc
26 from src.proto.grpc.testing
import control_pb2
27 from src.proto.grpc.testing
import messages_pb2
36 '/grpc.testing.BenchmarkService/UnaryCall')
38 '/grpc.testing.BenchmarkService/StreamingFromServer')
40 '/grpc.testing.BenchmarkService/StreamingCall')
44 """Benchmark client interface that exposes a non-blocking send_request()."""
46 def __init__(self, address: str, config: control_pb2.ClientConfig,
47 hist: histogram.Histogram):
49 unique_option = ((
'iv', random.random()),)
53 (arg.name, arg.str_value)
if arg.HasField(
'str_value')
else (
54 arg.name,
int(arg.int_value))
for arg
in config.channel_args)
57 if config.HasField(
'security_params'):
59 resources.test_root_certificates(),)
60 server_host_override_option = ((
61 'grpc.ssl_target_name_override',
62 config.security_params.server_host_override,
65 address, channel_credentials,
66 unique_option + channel_args + server_host_override_option)
68 self.
_channel = aio.insecure_channel(address,
69 options=unique_option +
73 if config.payload_config.WhichOneof(
'payload') ==
'simple_params':
75 self.
_stub = benchmark_service_pb2_grpc.BenchmarkServiceStub(
78 body=b
'\0' * config.payload_config.simple_params.req_size)
81 response_size=config.payload_config.simple_params.resp_size)
85 self.
_request = b
'\0' * config.payload_config.bytebuf_params.req_size
91 async
def run(self) -> None:
94 async
def stop(self) -> None:
103 def __init__(self, address: str, config: control_pb2.ClientConfig,
104 hist: histogram.Histogram):
110 start_time = time.monotonic()
118 async
def run(self) -> None:
122 await asyncio.gather(*senders)
133 def __init__(self, address: str, config: control_pb2.ClientConfig,
134 hist: histogram.Histogram):
140 call = self.
_stub.StreamingCall()
142 start_time = time.time()
146 await call.done_writing()
152 await asyncio.gather(*senders)
163 def __init__(self, address: str, config: control_pb2.ClientConfig,
164 hist: histogram.Histogram):
172 start_time = time.time()
181 await asyncio.gather(*senders)