In Python 3.4.1, I\'m trying to measure how long it takes for a function to run and complete then recording it. I\'m currently doing it this like so:
startti
I'll admit that I'm not very familiar with Python's asyncio, but I believe the issue is not in your timing, but in your useage of asyncio
.
I think you are just creating a future with the value of method(), however that is all that you are timing: the actual creation of this promise.
You are not timing the actual evaluation of the future value. This is why timing sleep(3) and method() take roughly the same amount of time.
I suggest trying to change asyncio.wait_for((method()), 5)
with yield from asyncio.wait_for((method()), 3)
or just timing method()
if you can.