r2 - 01 Jul 2005 - 10:33:39 - LisaDusseaultYou are here: OSAF >  Projects Web  >  DevelopmentHome > PerformanceProject > RuntimePerformance > HotShot

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

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Open Source Applications Foundation
Except where otherwise noted, this site and its content are licensed by OSAF under an Creative Commons License, Attribution Only 3.0.
See list of page contributors for attributions.