Permalink
Browse files

star caching preparations

  • Loading branch information...
davidhalter committed Nov 21, 2012
1 parent 395c5cd commit 890748ac9f0fa5b42bb50ac51c31526fea273bf2
Showing with 22 additions and 15 deletions.
  1. +2 −0 jedi/evaluate.py
  2. +8 −0 jedi/imports.py
  3. +12 −15 test/regression.py
View
@@ -86,6 +86,8 @@ def clear_caches():
follow_statement.reset()
+ imports.imports_processed = 0
+
def memoize_default(default=None):
"""
View
@@ -264,6 +264,12 @@ def strip_imports(scopes):
return result
+def star_import_cache(func):
+ def wrapper(scope, *args, **kwargs):
+ return func(scope, *args, **kwargs)
+ return wrapper
+
+@star_import_cache
def remove_star_imports(scope, ignored_modules=[]):
"""
Check a module for star imports:
@@ -279,4 +285,6 @@ def remove_star_imports(scope, ignored_modules=[]):
modules += new
# Filter duplicate modules.
+ if len(modules) > 10:
+ print scope, len(modules)
return set(modules)
View
@@ -235,14 +235,16 @@ def test_full_name(self):
== 'os.path.join'
class TestSpeed(Base):
- def _check_speed(time_per_run, number=10):
+ def _check_speed(time_per_run, number=4, run_warm=True):
""" Speed checks should typically be very tolerant. Some machines are
faster than others, but the tests should still pass. These tests are
here to assure that certain effects that kill jedi performance are not
reintroduced to Jedi."""
def decorated(func):
@functools.wraps(func)
def wrapper(self):
+ if run_warm:
+ func(self)
first = time.time()
for i in range(number):
func(self)
@@ -252,25 +254,20 @@ def wrapper(self):
return wrapper
return decorated
- # skip by removing test
@_check_speed(0.1)
- def _test_os_path_join(self):
+ def test_os_path_join(self):
s = "from posixpath import join; join('', '')."
assert len(self.complete(s)) > 10 # is a str completion
- def test_2(self):
- # preload
- s = 'from scipy.weave import inline; inline('
- self.get_in_function_call(s)
-
- #@unittest.expectedFailure
- @_check_speed(0.6, number=1)
- def _test_new(self):
+ @_check_speed(0.2, number=1)
+ def test_scipy_speed(self):
s = 'import scipy.weave; scipy.weave.inline('
- api.set_debug_function(api.debug.print_to_stdout)
- #print(self.get_in_function_call(s))
- api.set_debug_function(None)
- #print(api.imports.imports_processed)
+ #api.set_debug_function(api.debug.print_to_stdout)
+ script = api.Script(s, 1, len(s), '')
+ script.get_in_function_call()
+ # self.get_in_function_call(s)
+ #api.set_debug_function(None)
+ print(api.imports.imports_processed)
if __name__ == '__main__':

0 comments on commit 890748a

Please sign in to comment.