X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/0ef6699add983199b5e94e9a7d4d95edaff1064b..681f805ef4688c7ea450f5e72a15dad818809734:/stg-prof diff --git a/stg-prof b/stg-prof index 8bbb623..de7bd13 100755 --- a/stg-prof +++ b/stg-prof @@ -40,13 +40,14 @@ if bin == 'bin' and prefix != sys.prefix: from stgit.main import main -start_time = time.time() -def timer(): - return time.time() - start_time - -prof = profile.Profile(timer) -try: - prof.run('main()') -except SystemExit: - pass -pstats.Stats(prof).strip_dirs().sort_stats(-1).print_stats().print_callees() +if __name__ == '__main__': + start_time = time.time() + def timer(): + return time.time() - start_time + + prof = profile.Profile(timer) + try: + prof.run('main()') + except SystemExit: + pass + pstats.Stats(prof).strip_dirs().sort_stats(-1).print_stats().print_callees()