DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Profiling Python Code

01.04.2006
| 486 views |
  • submit to reddit
        
import hotshot
prof = hotshot.Profile("hotshot_stats_file")
prof.runcall(main)
prof.close()

from hotshot import stats
s = stats.load("hotshot_stats_file"")
s.sort_stats("time").print_stats()