Remove unit test class from speed tests

This commit is contained in:
Dave Halter
2017-12-13 19:22:45 +01:00
parent e03afc60ef
commit 94e2e92888

View File

@@ -6,44 +6,47 @@ should.
import time import time
import functools import functools
from .helpers import TestCase, cwd_at from .helpers import cwd_at
import jedi import jedi
class TestSpeed(TestCase):
def _check_speed(time_per_run, number=4, run_warm=True): 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
reintroduced to Jedi.""" reintroduced to Jedi."""
def decorated(func): def decorated(func):
@functools.wraps(func) @functools.wraps(func)
def wrapper(self): def wrapper():
if run_warm: if run_warm:
func(self) func()
first = time.time() first = time.time()
for i in range(number): for i in range(number):
func(self) func()
single_time = (time.time() - first) / number single_time = (time.time() - first) / number
message = 'speed issue %s, %s' % (func, single_time) message = 'speed issue %s, %s' % (func, single_time)
assert single_time < time_per_run, message assert single_time < time_per_run, message
return wrapper return wrapper
return decorated return decorated
@_check_speed(0.2)
def test_os_path_join(self): @_check_speed(0.2)
def test_os_path_join():
s = "from posixpath import join; join('', '')." s = "from posixpath import join; join('', '')."
assert len(jedi.Script(s).completions()) > 10 # is a str completion assert len(jedi.Script(s).completions()) > 10 # is a str completion
@_check_speed(0.15)
def test_scipy_speed(self): @_check_speed(0.15)
def test_scipy_speed():
s = 'import scipy.weave; scipy.weave.inline(' s = 'import scipy.weave; scipy.weave.inline('
script = jedi.Script(s, 1, len(s), '') script = jedi.Script(s, 1, len(s), '')
script.call_signatures() script.call_signatures()
#print(jedi.imports.imports_processed) #print(jedi.imports.imports_processed)
@_check_speed(0.8)
@cwd_at('test') @_check_speed(0.8)
def test_precedence_slowdown(self): @cwd_at('test')
def test_precedence_slowdown():
""" """
Precedence calculation can slow down things significantly in edge Precedence calculation can slow down things significantly in edge
cases. Having strange recursion structures increases the problem. cases. Having strange recursion structures increases the problem.
@@ -52,8 +55,9 @@ class TestSpeed(TestCase):
line = len(f.read().splitlines()) line = len(f.read().splitlines())
assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions() assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions()
@_check_speed(0.1)
def test_no_repr_computation(self): @_check_speed(0.1)
def test_no_repr_computation():
""" """
For Interpreter completion aquisition of sourcefile can trigger For Interpreter completion aquisition of sourcefile can trigger
unwanted computation of repr(). Exemple : big pandas data. unwanted computation of repr(). Exemple : big pandas data.