From: Mike Bayer Date: Mon, 9 Mar 2015 19:19:49 +0000 (-0400) Subject: - add a callers option X-Git-Tag: rel_1_0_0b1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=611d88d234319b730b521734418ff7e9aafb1716;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - add a callers option --- diff --git a/examples/performance/__init__.py b/examples/performance/__init__.py index 15dbe60ab8..88ae9b7dc6 100644 --- a/examples/performance/__init__.py +++ b/examples/performance/__init__.py @@ -241,6 +241,7 @@ class Profiler(object): self.runsnake = options.runsnake self.profile = options.profile self.dump = options.dump + self.callers = options.callers self.num = options.num self.echo = options.echo self.stats = [] @@ -298,7 +299,6 @@ class Profiler(object): pr.disable() stats = pstats.Stats(pr).sort_stats('cumulative') - # stats.print_callers() self.stats.append(TestResult(self, fn, stats=stats)) return result @@ -355,6 +355,9 @@ class Profiler(object): parser.add_argument( '--dump', action='store_true', help='dump full call profile (implies --profile)') + parser.add_argument( + '--callers', action='store_true', + help='print callers as well (implies --dump)') parser.add_argument( '--runsnake', action='store_true', help='invoke runsnakerun (implies --profile)') @@ -363,6 +366,7 @@ class Profiler(object): help="Echo SQL output") args = parser.parse_args() + args.dump = args.dump or args.callers args.profile = args.profile or args.dump or args.runsnake if cls.name is None: @@ -410,6 +414,8 @@ class TestResult(object): def _dump(self): self.stats.sort_stats('time', 'calls') self.stats.print_stats() + if self.profile.callers: + self.stats.print_callers() def _runsnake(self): filename = "%s.profile" % self.test.__name__