mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
speed test for slow precedence issues
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
addopts = --doctest-modules
|
addopts = --doctest-modules
|
||||||
|
|
||||||
# Ignore broken files in blackbox test directories
|
# Ignore broken files in blackbox test directories
|
||||||
norecursedirs = .* docs completion refactor absolute_import namespace_package scripts extensions
|
norecursedirs = .* docs completion refactor absolute_import namespace_package scripts extensions speed
|
||||||
|
|
||||||
# Activate `clean_jedi_cache` fixture for all tests. This should be
|
# Activate `clean_jedi_cache` fixture for all tests. This should be
|
||||||
# fine as long as we are using `clean_jedi_cache` as a session scoped
|
# fine as long as we are using `clean_jedi_cache` as a session scoped
|
||||||
|
|||||||
37
test/speed/precedence.py
Normal file
37
test/speed/precedence.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
def whatever(code):
|
||||||
|
if '.' in code:
|
||||||
|
another(code[:code.index('.') - 1] + '!')
|
||||||
|
else:
|
||||||
|
another(code + '.')
|
||||||
|
|
||||||
|
|
||||||
|
def another(code2):
|
||||||
|
call(ret(code2 + 'haha'))
|
||||||
|
|
||||||
|
whatever('1.23')
|
||||||
|
whatever('1,23')
|
||||||
|
|
||||||
|
|
||||||
|
def ret2(code4):
|
||||||
|
if 1:
|
||||||
|
if 2:
|
||||||
|
return code4 + 'i'
|
||||||
|
else:
|
||||||
|
return code4 + 'k'
|
||||||
|
else:
|
||||||
|
if 2:
|
||||||
|
return code4 + 'l'
|
||||||
|
else:
|
||||||
|
return code4 + 'h'
|
||||||
|
|
||||||
|
|
||||||
|
def ret(code5):
|
||||||
|
if 2:
|
||||||
|
return ret2(code5 + 'r')
|
||||||
|
else:
|
||||||
|
return ret2(code5 + 'k')
|
||||||
|
|
||||||
|
|
||||||
|
def call(code3):
|
||||||
|
code3 = '1' + ret(code3)
|
||||||
|
code3.partition
|
||||||
@@ -6,7 +6,7 @@ should.
|
|||||||
import time
|
import time
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from .helpers import TestCase
|
from .helpers import TestCase, cwd_at
|
||||||
import jedi
|
import jedi
|
||||||
|
|
||||||
class TestSpeed(TestCase):
|
class TestSpeed(TestCase):
|
||||||
@@ -25,7 +25,7 @@ class TestSpeed(TestCase):
|
|||||||
func(self)
|
func(self)
|
||||||
single_time = (time.time() - first) / number
|
single_time = (time.time() - first) / number
|
||||||
print('\nspeed', func, single_time)
|
print('\nspeed', func, single_time)
|
||||||
assert single_time < time_per_run
|
assert single_time < time_per_run, 'Too slow.'
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorated
|
return decorated
|
||||||
|
|
||||||
@@ -40,3 +40,14 @@ class TestSpeed(TestCase):
|
|||||||
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.1)
|
||||||
|
@cwd_at('test')
|
||||||
|
def test_precedence_slowdown(self):
|
||||||
|
"""
|
||||||
|
Precedence calculation can slow down things significantly in edge
|
||||||
|
cases. Having strange recursion structures increases the problem.
|
||||||
|
"""
|
||||||
|
with open('speed/precedence.py') as f:
|
||||||
|
line = len(f.read().splitlines())
|
||||||
|
assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions()
|
||||||
|
|||||||
Reference in New Issue
Block a user