Last active
June 20, 2018 22:32
-
-
Save micbou/28eae3625de4820dac04b3b38ee0789b to your computer and use it in GitHub Desktop.
Completion measurements of some common modules with Jedi for Python 2.7 and 3.6 environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jedi | |
import sys | |
import time | |
def measure(module, version): | |
sys.stdout.write('Completing {} in '.format(module)) | |
code = 'import {0}\n{0}.'.format(module) | |
environment = jedi.get_system_environment(version) | |
# Warmup | |
jedi.Script(code, environment=environment).completions() | |
total_time = 0 | |
nb_runs = 0 | |
while total_time < 5: | |
tic = time.time() | |
jedi.Script(code, environment=environment).completions() | |
total_time += time.time() - tic | |
nb_runs += 1 | |
print('{:.3}s ({} runs)'.format(total_time/nb_runs, nb_runs)) | |
for version in ['2.7', '3.6']: | |
print('Using Python {} as environment:'.format(version)) | |
measure('os', version) | |
measure('numpy', version) | |
measure('cv2', version) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment