Changeset 1271

Show
Ignore:
Timestamp:
05/11/07 11:31:33 (2 years ago)
Author:
wrobe..@pld-linux.org
Message:

- allow to run gaphor with profiling enabled

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/utils/command/run.py

    r1238 r1271  
    1919        ('model=', 'm', 'load a model file'), 
    2020        ('coverage', None, 'Calculate coverage (utils/coverage.py)'), 
     21        ('profile', 'p', 'Run with profiling enabled'), 
    2122    ] 
    2223 
     
    3031        self.coverage = None 
    3132        self.verbosity = 2 
     33        self.profile = None 
    3234 
    3335    def finalize_options(self): 
     
    3739    def run(self): 
    3840        print 'Starting Gaphor...' 
     41 
    3942        if self.model: 
    4043            print 'Starting with model file', self.model 
     
    105108            print 'Launching Gaphor...' 
    106109            #gaphor.main(self.model) 
    107             load_entry_point('gaphor==0.10.5', 'console_scripts', 'gaphor')() 
     110            starter = load_entry_point('gaphor==0.10.5', 'console_scripts', 'gaphor') 
     111 
     112            if self.profile: 
     113                print 'Enabling profiling...' 
     114                import hotshot, hotshot.stats 
     115                prof = hotshot.Profile('gaphor.prof') 
     116                prof.runcall(starter) 
     117                prof.close() 
     118                stats = hotshot.stats.load('gaphor.prof') 
     119                stats.strip_dirs() 
     120                stats.sort_stats('time', 'calls') 
     121                stats.print_stats(20) 
     122            else: 
     123                starter() 
    108124 
    109125    sub_commands = [('build', None)]