saving cProfile results to readable external file

后端 未结 5 1760
清酒与你
清酒与你 2021-02-19 01:16

I am using cProfile try to profile my codes:

pr = cProfile.Profile()
pr.enable()
my_func()   # the code I want to profile
pr.disable()
pr.print_stat         


        
5条回答
  •  醉话见心
    2021-02-19 02:02

    you can use dump_stats. In Python 3.8:

    with cProfile.Profile() as pr:
        my_func()  
    
    pr.dump_stats('/path/to/filename.prof')
    

提交回复
热议问题