forked from VimPlug/jedi
star caching preparations
This commit is contained in:
@@ -86,6 +86,8 @@ def clear_caches():
|
|||||||
|
|
||||||
follow_statement.reset()
|
follow_statement.reset()
|
||||||
|
|
||||||
|
imports.imports_processed = 0
|
||||||
|
|
||||||
|
|
||||||
def memoize_default(default=None):
|
def memoize_default(default=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -264,6 +264,12 @@ def strip_imports(scopes):
|
|||||||
return result
|
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=[]):
|
def remove_star_imports(scope, ignored_modules=[]):
|
||||||
"""
|
"""
|
||||||
Check a module for star imports:
|
Check a module for star imports:
|
||||||
@@ -279,4 +285,6 @@ def remove_star_imports(scope, ignored_modules=[]):
|
|||||||
modules += new
|
modules += new
|
||||||
|
|
||||||
# Filter duplicate modules.
|
# Filter duplicate modules.
|
||||||
|
if len(modules) > 10:
|
||||||
|
print scope, len(modules)
|
||||||
return set(modules)
|
return set(modules)
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class TestFeature(Base):
|
|||||||
== 'os.path.join'
|
== 'os.path.join'
|
||||||
|
|
||||||
class TestSpeed(Base):
|
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
|
""" Speed checks should typically be very tolerant. Some machines are
|
||||||
faster than others, but the tests should still pass. These tests 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
|
here to assure that certain effects that kill jedi performance are not
|
||||||
@@ -243,6 +243,8 @@ class TestSpeed(Base):
|
|||||||
def decorated(func):
|
def decorated(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def wrapper(self):
|
def wrapper(self):
|
||||||
|
if run_warm:
|
||||||
|
func(self)
|
||||||
first = time.time()
|
first = time.time()
|
||||||
for i in range(number):
|
for i in range(number):
|
||||||
func(self)
|
func(self)
|
||||||
@@ -252,25 +254,20 @@ class TestSpeed(Base):
|
|||||||
return wrapper
|
return wrapper
|
||||||
return decorated
|
return decorated
|
||||||
|
|
||||||
# skip by removing test
|
|
||||||
@_check_speed(0.1)
|
@_check_speed(0.1)
|
||||||
def _test_os_path_join(self):
|
def test_os_path_join(self):
|
||||||
s = "from posixpath import join; join('', '')."
|
s = "from posixpath import join; join('', '')."
|
||||||
assert len(self.complete(s)) > 10 # is a str completion
|
assert len(self.complete(s)) > 10 # is a str completion
|
||||||
|
|
||||||
def test_2(self):
|
@_check_speed(0.2, number=1)
|
||||||
# preload
|
def test_scipy_speed(self):
|
||||||
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):
|
|
||||||
s = 'import scipy.weave; scipy.weave.inline('
|
s = 'import scipy.weave; scipy.weave.inline('
|
||||||
api.set_debug_function(api.debug.print_to_stdout)
|
#api.set_debug_function(api.debug.print_to_stdout)
|
||||||
#print(self.get_in_function_call(s))
|
script = api.Script(s, 1, len(s), '')
|
||||||
api.set_debug_function(None)
|
script.get_in_function_call()
|
||||||
#print(api.imports.imports_processed)
|
# self.get_in_function_call(s)
|
||||||
|
#api.set_debug_function(None)
|
||||||
|
print(api.imports.imports_processed)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user