]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add a callers option
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 9 Mar 2015 19:19:49 +0000 (15:19 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 9 Mar 2015 19:19:49 +0000 (15:19 -0400)
examples/performance/__init__.py

index 15dbe60ab855d9e4ea0fbe00d2b79e53fa5f813e..88ae9b7dc6ce6d2a68a4e6001b2d3a19c64e6a3c 100644 (file)
@@ -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__