mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-14 17:47:05 +08:00
Remove unit test class from speed tests
This commit is contained in:
@@ -6,10 +6,10 @@ 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
|
||||||
@@ -17,33 +17,36 @@ class TestSpeed(TestCase):
|
|||||||
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)
|
@_check_speed(0.2)
|
||||||
def test_os_path_join(self):
|
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)
|
@_check_speed(0.15)
|
||||||
def test_scipy_speed(self):
|
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)
|
@_check_speed(0.8)
|
||||||
@cwd_at('test')
|
@cwd_at('test')
|
||||||
def test_precedence_slowdown(self):
|
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)
|
@_check_speed(0.1)
|
||||||
def test_no_repr_computation(self):
|
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user