1
1
import asyncio
2
2
import logging
3
+ import sys
3
4
from asyncio import Event
4
5
from typing import AsyncGenerator , Tuple
5
6
14
15
from rsocket .streams .stream_from_async_generator import StreamFromAsyncGenerator
15
16
from rsocket .transports .tcp import TransportTCP
16
17
from tests .rsocket .helpers import to_json_bytes , create_large_random_data
17
-
18
+ from tests . tools . helpers import measure_time
18
19
19
20
data_size = 1920 # * 1080 * 3
20
21
large_data = create_large_random_data (data_size )
@@ -104,7 +105,7 @@ async def request_fragmented_stream(self):
104
105
async def __aenter__ (self ):
105
106
logging .info ('Connecting to server at localhost:%s' , self ._server_port )
106
107
107
- connection = await asyncio .open_connection ('localhost' , self ._server_port )
108
+ connection = await asyncio .open_connection ('localhost' , self ._server_port , limit = data_size + 3000 )
108
109
109
110
self ._client = AwaitableRSocket (RSocketClient (
110
111
single_transport_provider (TransportTCP (* connection , read_buffer_size = data_size + 3000 )),
@@ -116,3 +117,16 @@ async def __aenter__(self):
116
117
117
118
async def __aexit__ (self , exc_type , exc_val , exc_tb ):
118
119
await self ._client .__aexit__ (exc_type , exc_val , exc_tb )
120
+
121
+
122
+ async def run_client ():
123
+ async with PerformanceClient (6565 ) as client :
124
+ for i in range (10000 ):
125
+ result = await measure_time (client .large_request ())
126
+ # print(result.delta)
127
+
128
+
129
+ if __name__ == '__main__' :
130
+ port = sys .argv [1 ] if len (sys .argv ) > 1 else 6565
131
+ logging .basicConfig (level = logging .ERROR )
132
+ asyncio .run (run_client ())
0 commit comments