Project

General

Profile

« Previous | Next » 

Revision 847

bin/map: Added profile_to option which turns on profiling to the specified file

View differences:

bin/map
23 23
    if type(name) == str and name.startswith(':'): return name[1:]
24 24
    else: return None
25 25

  
26
def main():
26
def main_():
27 27
    ex_tracker = exc.ExTracker()
28 28
    
29 29
    env_names = []
30 30
    def usage_err():
31 31
        raise SystemExit('Usage: ' + opts.env_usage(env_names, True)
32
            +' [commit=1] [test=1] [verbose=1] [debug=1] '+sys.argv[0]
33
            +' [map_path...] [<input] [>output]')
32
            +' [commit=1] [test=1] [verbose=1] [debug=1] [profile_to=...] '
33
            +sys.argv[0]+' [map_path...] [<input] [>output]')
34 34
    
35 35
    # Get db config from env vars
36 36
    db_config_names = ['engine', 'host', 'user', 'password', 'database']
......
235 235
        else: # output is CSV
236 236
            raise NotImplementedError('CSV output not supported yet')
237 237

  
238
def main():
239
    try: main_()
240
    except Parser.SyntaxException, e: raise SystemExit(str(e))
241

  
238 242
if __name__ == '__main__':
239
    try: main()
240
    except Parser.SyntaxException, e: raise SystemExit(str(e))
243
    profile_to = opts.get_env_var('profile_to', None)
244
    if profile_to != None:
245
        import cProfile
246
        cProfile.run(main.func_code, profile_to)
247
    else: main()

Also available in: Unified diff