Skip to content

Commit c7eaeb9

Browse files
committed
add jedi cache warmup/test
1 parent 02f9221 commit c7eaeb9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

ci/job.test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ jobs:
106106
- script: ${{ platform.activate }} && jupyter labextension list
107107
displayName: list labextensions after build
108108

109+
- script: ${{ platform.activate }} && python scripts/jedi_cache.py
110+
displayName: warm up jedi cache
111+
109112
- script: ${{ platform.activate }} && python scripts/atest.py
110113
displayName: run browser tests
111114

scripts/jedi_cache.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
""" utility script to warm up/validate the jedi cache
2+
"""
3+
import sys
4+
import time
5+
6+
import IPython
7+
import jedi
8+
import jupyterlab
9+
10+
SOURCE_TEMPLATE = """
11+
import {module}
12+
{module}."""
13+
14+
MODULES_TO_CACHE = [
15+
"sys",
16+
"itertools",
17+
"IPython",
18+
"statistics",
19+
"os",
20+
"time",
21+
*sys.modules,
22+
]
23+
24+
25+
def warm_up_one(module):
26+
start = time.time()
27+
script = jedi.Script(SOURCE_TEMPLATE.format(module=module))
28+
completions = len(script.complete(3, len("{}.".format(module))))
29+
end = time.time()
30+
print(module, completions, end - start)
31+
32+
33+
if __name__ == "__main__":
34+
print(IPython.__version__)
35+
print(jupyterlab.__version__)
36+
start = time.time()
37+
modules = sorted(set(sys.argv[1:] or MODULES_TO_CACHE))
38+
[warm_up_one(module) for module in modules]
39+
end = time.time()
40+
print("------------------")
41+
print(len(modules), "modules", end - start)

0 commit comments

Comments
 (0)