diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-06 21:11:27 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-08-06 21:11:27 +0000 |
| commit | 8fc5005dfe3eb66a46470ad8a8c7b95fc4d6bdca (patch) | |
| tree | ae9e27d12c9fbf8297bb90469509e1cb6a206242 /lib/sqlalchemy/test/profiling.py | |
| parent | 7638aa7f242c6ea3d743aa9100e32be2052546a6 (diff) | |
| download | sqlalchemy-8fc5005dfe3eb66a46470ad8a8c7b95fc4d6bdca.tar.gz | |
merge 0.6 series to trunk.
Diffstat (limited to 'lib/sqlalchemy/test/profiling.py')
| -rw-r--r-- | lib/sqlalchemy/test/profiling.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/sqlalchemy/test/profiling.py b/lib/sqlalchemy/test/profiling.py index ca4b31cbd..8cab6ceba 100644 --- a/lib/sqlalchemy/test/profiling.py +++ b/lib/sqlalchemy/test/profiling.py @@ -6,8 +6,9 @@ in a more fine-grained way than nose's profiling plugin. """ import os, sys -from sqlalchemy.util import function_named -import config +from sqlalchemy.test import config +from sqlalchemy.test.util import function_named, gc_collect +from nose import SkipTest __all__ = 'profiled', 'function_call_count', 'conditional_call_count' @@ -162,15 +163,22 @@ def conditional_call_count(discriminator, categories): def _profile(filename, fn, *args, **kw): global profiler if not profiler: - profiler = 'hotshot' if sys.version_info > (2, 5): try: import cProfile profiler = 'cProfile' except ImportError: pass + if not profiler: + try: + import hotshot + profiler = 'hotshot' + except ImportError: + profiler = 'skip' - if profiler == 'cProfile': + if profiler == 'skip': + raise SkipTest('Profiling not supported on this platform') + elif profiler == 'cProfile': return _profile_cProfile(filename, fn, *args, **kw) else: return _profile_hotshot(filename, fn, *args, **kw) @@ -179,7 +187,7 @@ def _profile_cProfile(filename, fn, *args, **kw): import cProfile, gc, pstats, time load_stats = lambda: pstats.Stats(filename) - gc.collect() + gc_collect() began = time.time() cProfile.runctx('result = fn(*args, **kw)', globals(), locals(), @@ -192,7 +200,7 @@ def _profile_hotshot(filename, fn, *args, **kw): import gc, hotshot, hotshot.stats, time load_stats = lambda: hotshot.stats.load(filename) - gc.collect() + gc_collect() prof = hotshot.Profile(filename) began = time.time() prof.start() |
