Using HotShot to do Performance Timing in Chandler
The only tricky part about using hotshot is making the call that you want to do timing for. You pass in a callable, *args, and **kwds. In the example below I called super(DetailRoot, self).render without any args or kwds since no parameters are needed.
import hotshot, hotshot.stats
profiler = hotshot.Profile('DetailViewProfile.hotshot')
args = []
kwds = {}
profiler.runcall(super(DetailRoot, self).render, *args, **kwds)
profiler.close()
stats = hotshot.stats.load('DetailViewProfile.hotshot')
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(50)
stats.sort_stats('calls')
stats.print_stats(10)
stats.sort_stats('cum')
stats.print_stats(10)
It uses stdout to output three fairly self-explanitory profiles.
--
DonnDenman - 05 Aug 2004