Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Generate 10 requests per client
Browse files Browse the repository at this point in the history
  • Loading branch information
blampe committed Mar 8, 2016
1 parent ea023d6 commit 66cba92
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions benchmarks/test_roundtrip.py
Expand Up @@ -23,6 +23,12 @@
from tchannel import TChannel, thrift


service = thrift.load(
path='examples/guide/keyvalue/service.thrift',
service='benchmark-server',
)


def test_roundtrip(benchmark):
loop = ioloop.IOLoop.current()

Expand All @@ -31,23 +37,24 @@ def test_roundtrip(benchmark):

clients = [TChannel('benchmark-client') for _ in range(10)]

service = thrift.load(
path='examples/guide/keyvalue/service.thrift',
service='benchmark-server',
)
service.hostport = server.hostport

@server.thrift.register(service.KeyValue)
def getValue(request):
return 'bar'

def roundtrip():
@gen.coroutine
def doit():
yield [
client.thrift(service.KeyValue.getValue("foo"))
for client in clients
]
futures = []
# 10 clients send 10 requests concurrently
for client in clients:
for _ in range(10):
futures.append(
client.thrift(
service.KeyValue.getValue("foo"),
hostport=server.hostport,
)
)
yield futures

return loop.run_sync(doit)

Expand Down

0 comments on commit 66cba92

Please sign in to comment.