diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-12 13:01:34 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-12 13:01:34 -0500 |
| commit | 0d71ea8126137d2b3d4141aa0fb30c2e64376d44 (patch) | |
| tree | edcc99227a474a61686f277fdc36cf2b0960e14c /test/lib/profiling.py | |
| parent | 6d5dd2214a4cc6340d8f07147a43fac03a12b040 (diff) | |
| download | sqlalchemy-0d71ea8126137d2b3d4141aa0fb30c2e64376d44.tar.gz | |
- inlinings and callcount reductions
- add test coverage for the rare case of noload->lazyload + pickle
Diffstat (limited to 'test/lib/profiling.py')
| -rw-r--r-- | test/lib/profiling.py | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/test/lib/profiling.py b/test/lib/profiling.py index eeb3901cb..6216e75b1 100644 --- a/test/lib/profiling.py +++ b/test/lib/profiling.py @@ -14,6 +14,9 @@ __all__ = 'profiled', 'function_call_count', 'conditional_call_count' all_targets = set() profile_config = { 'targets': set(), 'report': True, + 'print_callers':False, + 'print_callees':False, + 'graphic':False, 'sort': ('time', 'calls'), 'limit': None } profiler = None @@ -47,21 +50,35 @@ def profiled(target=None, **target_opts): elapsed, load_stats, result = _profile( filename, fn, *args, **kw) - - report = target_opts.get('report', profile_config['report']) - if report: - sort_ = target_opts.get('sort', profile_config['sort']) - limit = target_opts.get('limit', profile_config['limit']) - print "Profile report for target '%s' (%s)" % ( - target, filename) - - stats = load_stats() - stats.sort_stats(*sort_) - if limit: - stats.print_stats(limit) - else: - stats.print_stats() - #stats.print_callers() + + graphic = target_opts.get('graphic', profile_config['graphic']) + if graphic: + os.system("runsnake %s" % filename) + else: + report = target_opts.get('report', profile_config['report']) + if report: + sort_ = target_opts.get('sort', profile_config['sort']) + limit = target_opts.get('limit', profile_config['limit']) + print "Profile report for target '%s' (%s)" % ( + target, filename) + + stats = load_stats() + stats.sort_stats(*sort_) + if limit: + stats.print_stats(limit) + else: + stats.print_stats() + + print_callers = target_opts.get('print_callers', + profile_config['print_callers']) + if print_callers: + stats.print_callers() + + print_callees = target_opts.get('print_callees', + profile_config['print_callees']) + if print_callees: + stats.print_callees() + os.unlink(filename) return result return decorate |
