[wingide-users] Profile a python script from within WingIde

Wingware Support support at wingware.com
Mon Sep 9 10:27:44 EDT 2013

Werner F. Bruhin wrote:
> Is there a way of profiling a Python script in WingIDE and getting 
> statistics displayed in a way which is easy to analyse?

Wing doesn't yet have integrated profiling support.  It's something 
we'ld like to add eventually although it's lower priority since it's 
pretty easy to profile Python w/o IDE support.  Also, it's often a good 
idea to have a way to start/stop profiling in the shipped code for the 
inevitable cases where something runs slowly only in the field.

In case it's useful, here is a quick example of using cProfile and 
pstats to profile a call.  This forms the basis of the 
internal-profile-start and internal-profile-stop commands in Wing, which 
let us get profiles from users (in our case the function passed to 
runcall is a nested GUI event loop):

       import cProfile, pstats

       profiler = cProfile.Profile()

       stats = pstats.Stats(profiler)
       stats.sort_stats('cumulative', 'calls')
       stats.sort_stats('time', 'calls')

Showing both 'cumulative' and 'time' stats helps reveal hotspots in more 

I hope this is useful...


Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list