Python-stats: wie Schreibe ich es auf eine (lesbare) Datei

Ich bin mit Python ' s hotshot-profiler: http://docs.python.org/2/library/hotshot.html

Er zeigt, wie drucken Sie die Statistiken:

stats.print_stats(20)

Aber wie bekomme ich das in eine Datei? Ich bin mir nicht sicher, wie man an die Informationen, so kann ich schreiben es in eine Datei mit write().

EDIT:

Möchte ich den gleichen, leicht lesbaren Ergebnis wie gedruckt, wenn es auf diese Weise getan:

stats = hotshot.stats.load("stones.prof")
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(20) 

Also es sieht wie folgt aus:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    3.295    3.295   10.090   10.090 pystone.py:79(Proc0)

(Also nicht Aussehen, wenn ich öffnen Sie die Steine.prof)

InformationsquelleAutor user984003 | 2012-11-23
Schreibe einen Kommentar