Whitespace-sensitive languages are the worst

pull/20753/head
Richard Belleville 5 years ago
parent da9f5f78fe
commit d5d9bc0a0d
  1. 49
      src/python/grpcio_tests/tests/stress/unary_stream_benchmark.py

@ -21,36 +21,37 @@ import sys
import time import time
import contextlib import contextlib
try: _PORT = 5741
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2 _MESSAGE_SIZE = 4
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2_grpc _RESPONSE_COUNT = 32 * 1024
_SERVER_CODE = """
import datetime
import threading
import grpc
from concurrent import futures
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2_grpc
_PORT = 5741 class Handler(unary_stream_benchmark_pb2_grpc.UnaryStreamBenchmarkServiceServicer):
_MESSAGE_SIZE = 4
_RESPONSE_COUNT = 32 * 1024
_SERVER_CODE = """ def Benchmark(self, request, context):
import datetime payload = b'\\x00\\x01' * int(request.message_size / 2)
import threading for _ in range(request.response_count):
import grpc yield unary_stream_benchmark_pb2.BenchmarkResponse(response=payload)
from concurrent import futures
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2_grpc
class Handler(unary_stream_benchmark_pb2_grpc.UnaryStreamBenchmarkServiceServicer):
def Benchmark(self, request, context): server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
payload = b'\\x00\\x01' * int(request.message_size / 2) server.add_insecure_port('[::]:%d')
for _ in range(request.response_count): unary_stream_benchmark_pb2_grpc.add_UnaryStreamBenchmarkServiceServicer_to_server(Handler(), server)
yield unary_stream_benchmark_pb2.BenchmarkResponse(response=payload) server.start()
server.wait_for_termination()
""" % _PORT
try:
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2
from src.python.grpcio_tests.tests.stress import unary_stream_benchmark_pb2_grpc
server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
server.add_insecure_port('[::]:%d')
unary_stream_benchmark_pb2_grpc.add_UnaryStreamBenchmarkServiceServicer_to_server(Handler(), server)
server.start()
server.wait_for_termination()
""" % _PORT
_GRPC_CHANNEL_OPTIONS = [ _GRPC_CHANNEL_OPTIONS = [
('grpc.max_metadata_size', 16 * 1024 * 1024), ('grpc.max_metadata_size', 16 * 1024 * 1024),

Loading…
Cancel
Save