-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Did some benchmarks
Code example:
def timit(func):
async def wrapper():
begin = time.time()
await func()
stop = time.time()
print(f"total time of {func.__name__}: {stop - begin}")
return wrapper
@timit
async def natspy_main_nonconcurrent() :
client = NATS()
await client.connect('downtimer-nats1:4222')
for _ in range(1_000_0):
await client.publish("some", b"1")
await client.close()
@timit
async def natsrpy_main_nonconcurrent() :
client = Nats(
addrs=['downtimer-nats1:4222']
)
await client.startup()
for _ in range(1_000_0):
await client.publish("some", b"1")
await client.shutdown()
Output:
total time of natspy_main_nonconcurrent: 0.02205514907836914
total time of natsrpy_main_nonconcurrent: 2.494574546813965
Additional details:
- ran on Windows 10
- cProfile of natspy run shows 263970 function calls, cProfile of natsRpy shows 990367 function calls
- when ran with bigger payload (2 million symbols), natsRpy becomes faster then natspy not by a big margin
- running benchmark in Dockercontainer doesn't really change anything
- with using gather, function call count becomes somewhat similar, though perfomance is also strange (natspy 0.05 vs natsRpy 0.45)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels