Open alex-ber opened 2 months ago
This will be less error-prone for your clients. This is my implementation.
import yappi import contextlib @contextlib.contextmanager def yappi_profiler(stats_file_path, stats_format_type='callgrind'): yappi.start() try: yield finally: yappi.stop() yappi.get_func_stats() \ .save(stats_file_path, type=stats_format_type) yappi.clear_stats() @contextlib.asynccontextmanager async def ayappi_profiler(stats_file_path, stats_format_type='callgrind): yappi.start() try: yield finally: yappi.stop() yappi.get_func_stats() \ .save(stats_file_path, type=stats_format_type) yappi.clear_stats()
I am up for it if you can implement this + some tests around this. There might be some naming changes required as well since there is also get_thread_stats..etc.
get_thread_stats
This will be less error-prone for your clients. This is my implementation.