← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/callgrind into lp:launchpad

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/callgrind into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~abentley/launchpad/callgrind/+merge/94283

= Summary =
Support callgrind output for script profiling.

== Proposed fix ==
When the filename given to --profile begins with "callgrind.out", use callgrind format.

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==
None

== Demo and Q/A ==
None


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/services/scripts/base.py
-- 
https://code.launchpad.net/~abentley/launchpad/callgrind/+merge/94283
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/callgrind into lp:launchpad.
=== modified file 'lib/lp/services/scripts/base.py'
--- lib/lp/services/scripts/base.py	2012-01-06 11:08:30 +0000
+++ lib/lp/services/scripts/base.py	2012-02-22 22:07:29 +0000
@@ -25,6 +25,7 @@
     urlopen,
     )
 
+from bzrlib import lsprof
 from contrib.glock import (
     GlobalLock,
     LockAlreadyAcquired,
@@ -191,8 +192,9 @@
             scripts.logger_options(self.parser, default=self.loglevel)
             self.parser.add_option(
                 '--profile', dest='profile', metavar='FILE', help=(
-                        "Run the script under the profiler and save the "
-                        "profiling stats in FILE."))
+                        'Run the script under the profiler and save the '
+                        'profiling stats in FILE.  If FILE begins with '
+                        '"callgrind.out", the callgrind format is used.'))
         else:
             scripts.dummy_logger_options(self.parser)
 
@@ -349,7 +351,13 @@
         finally:
             install_feature_controller(original_feature_controller)
         if profiler:
-            profiler.dump_stats(self.options.profile)
+            basename = os.path.basename(self.options.profile)
+            if not basename.startswith('callgrind.out'):
+                profiler.dump_stats(self.options.profile)
+            else:
+                stats = lsprof.Stats(
+                    profiler.getstats(), {})
+                stats.save(self.options.profile, 'callgrind')
 
     def _init_zca(self, use_web_security):
         """Initialize the ZCA, this can be overridden for testing purposes."""


Follow ups