From 7dd72021c06803bac66b73f0c8687df0d459fd4a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 16 May 2010 21:28:07 +1200 Subject: Add way to run obnam under profiling. Add script to view profile data. --- obnam | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'obnam') diff --git a/obnam b/obnam index c8845fc7..4582304f 100755 --- a/obnam +++ b/obnam @@ -16,20 +16,31 @@ import logging +import os import sys import traceback import obnamlib -try: - obnamlib.App().run() -except obnamlib.AppException, e: - logging.critical(str(e)) - sys.stderr.write('Error: %s\n' % str(e)) - sys.exit(1) -except SystemExit, e: - sys.exit(e.code) -except BaseException, e: - logging.critical(traceback.format_exc()) - sys.stderr.write(traceback.format_exc()) - sys.exit(1) + +def main(): + try: + obnamlib.App().run() + except obnamlib.AppException, e: + logging.critical(str(e)) + sys.stderr.write('Error: %s\n' % str(e)) + sys.exit(1) + except SystemExit, e: + sys.exit(e.code) + except BaseException, e: + logging.critical(traceback.format_exc()) + sys.stderr.write(traceback.format_exc()) + sys.exit(1) + + +if __name__ == '__main__': + if os.environ.get('OBNAM_PROFILE') == 'yes': + import cProfile + cProfile.run('main()', 'obnam.prof') + else: + main() -- cgit v1.2.1