Python stats: how do I write it to a (human readable) file

后端 未结 5 1387
小蘑菇
小蘑菇 2021-02-07 00:39

I am using Python\'s hotshot profiler: http://docs.python.org/2/library/hotshot.html

It shows how to print the stats:

stats.print_stats(20)
5条回答
  •  天涯浪人
    2021-02-07 00:50

    How about output redirection?

    import sys
    import pstats
    sys.stdout = open('readable.profile', 'w')
    p = pstats.Stats('input.profile')
    p.print_stats()
    

提交回复
热议问题