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

Proposed by Aaron Bentley
Status: Rejected
Rejected by: Aaron Bentley
Proposed branch: lp:~abentley/launchpad/callgrind
Merge into: lp:launchpad
Diff against target: 38 lines (+11/-3)
1 file modified
lib/lp/services/scripts/base.py (+11/-3)
To merge this branch: bzr merge lp:~abentley/launchpad/callgrind
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Richard Harding (community) code* Approve
Review via email: mp+94283@code.launchpad.net

Commit message

Support callgrind output for script profiling.

Description of the change

= 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

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Nice!

It would be nice to have some sort of smoke test to make sure nobody accidentally breaks this. Other than that, seems good to me.

Revision history for this message
Richard Harding (rharding) :
review: Approve (code*)
Revision history for this message
j.c.sackett (jcsackett) wrote :

This looks like a clear improvement. Thanks, Aaron.

review: Approve
Revision history for this message
Aaron Bentley (abentley) wrote :

lifeless did not approve a LOC waiver for this.

Unmerged revisions

14786. By Aaron Bentley

Provide lsprof via a lower level.

14785. By Aaron Bentley

Merged stable into callgrind.

14784. By Aaron Bentley

Support callgrind.out profiling.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/scripts/base.py'
2--- lib/lp/services/scripts/base.py 2012-01-06 11:08:30 +0000
3+++ lib/lp/services/scripts/base.py 2012-02-22 22:10:26 +0000
4@@ -25,6 +25,7 @@
5 urlopen,
6 )
7
8+from bzrlib import lsprof
9 from contrib.glock import (
10 GlobalLock,
11 LockAlreadyAcquired,
12@@ -191,8 +192,9 @@
13 scripts.logger_options(self.parser, default=self.loglevel)
14 self.parser.add_option(
15 '--profile', dest='profile', metavar='FILE', help=(
16- "Run the script under the profiler and save the "
17- "profiling stats in FILE."))
18+ 'Run the script under the profiler and save the '
19+ 'profiling stats in FILE. If FILE begins with '
20+ '"callgrind.out", the callgrind format is used.'))
21 else:
22 scripts.dummy_logger_options(self.parser)
23
24@@ -349,7 +351,13 @@
25 finally:
26 install_feature_controller(original_feature_controller)
27 if profiler:
28- profiler.dump_stats(self.options.profile)
29+ basename = os.path.basename(self.options.profile)
30+ if not basename.startswith('callgrind.out'):
31+ profiler.dump_stats(self.options.profile)
32+ else:
33+ stats = lsprof.Stats(
34+ profiler.getstats(), {})
35+ stats.save(self.options.profile, 'callgrind')
36
37 def _init_zca(self, use_web_security):
38 """Initialize the ZCA, this can be overridden for testing purposes."""