[wingide-users] newbie question?

Wingware Support support at wingware.com
Thu Sep 6 18:31:31 MDT 2007


johnf wrote:
> Is there a simple way to use wing 3.0 (linux) to profile a program?

Wing doesn't yet have a profiler built in, so you'll need to use
the hotshot module that is included with Python.  Here's a simple
example of profiling a single function based on what we run when
we want to profile Wing itself:

def Run(a, b):
   """The thing you want to profile"""
   for i in range(a, b):
     print i

def Profile():
   """ Run w/ profiler. """

   print 'Starting profile'

   import hotshot, hotshot.stats
   prof = hotshot.Profile("profile.prof")
   prof.runcall(Run, 1, 2)
   prof.close()

   print 'Profile completed'

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

Hope that helps...

-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com



More information about the wingide-users mailing list