psf / pyperf

Toolkit to run Python benchmarks
http://pyperf.readthedocs.io/
MIT License
799 stars 78 forks source link

Add bench_async_func() #124

Closed methane closed 2 years ago

methane commented 2 years ago

Ref #121.

vstinner commented 2 years ago

I tested the example on my Fedora 35 with Python 3.10. I get:

async_sleep: Mean +- std dev: 1.32 ms +- 0.02 ms

That's interesting :-) Using await asyncio.sleep(1e-6), I get:

async_sleep: Mean +- std dev: 13.0 us +- 0.6 us
vstinner commented 2 years ago

Oh, sadly asyncio.run() doesn't exist in Python 3.6. Is it possible to reimplement asyncio.run() in pyperf on Python 3.6?

pyperf currently still supports Python 3.6: https://pyperf.readthedocs.io/en/latest/run_benchmark.html#install-pyperf

vstinner commented 2 years ago

With the proposed implementation (measure time inside asyncio.run and not outside), I agree that the implementation increases the accuracy and so it's worth it to add a new method ;-)

vstinner commented 2 years ago

I completed the changelog in commit 0814a4af62646b00cb2908db67f873c5910dd913.

vstinner commented 2 years ago

This change is now part of the just released pyperf 2.3.1.