Skip to content

Instantly share code, notes, and snippets.

@micbou
Last active June 20, 2018 22:32
Show Gist options
  • Save micbou/28eae3625de4820dac04b3b38ee0789b to your computer and use it in GitHub Desktop.
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
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