Last active
June 16, 2023 15:06
-
-
Save dbnicholson/c9ffc907546d8b866ad6210f6442a2e1 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import os | |
from shutil import rmtree | |
from subprocess import run | |
from timeit import repeat | |
CHANNEL_ID = 'f393c30f95fb4bec87f873b2013ec9e3' | |
KOLIBRI_0_15_BIN = os.path.expanduser( | |
'~/src/devel/kolibri/venv-0.15/bin/kolibri' | |
) | |
KOLIBRI_0_15_HOME = os.path.expanduser('~/src/devel/kolibri/home-0.15') | |
KOLIBRI_0_16_A12_BIN = os.path.expanduser( | |
'~/src/devel/kolibri/venv-0.16a12/bin/kolibri' | |
) | |
KOLIBRI_0_16_A12_HOME = os.path.expanduser('~/src/devel/kolibri/home-0.16a12') | |
KOLIBRI_0_16_A15_BIN = os.path.expanduser( | |
'~/src/devel/kolibri/venv-0.16a15/bin/kolibri' | |
) | |
KOLIBRI_0_16_A15_HOME = os.path.expanduser('~/src/devel/kolibri/home-0.16a15') | |
def setup(kolibri_bin, kolibri_home): | |
if os.path.exists(kolibri_home): | |
rmtree(kolibri_home) | |
env = os.environ.copy() | |
env['KOLIBRI_HOME'] = kolibri_home | |
setup_cmd = (kolibri_bin, 'configure', 'setup') | |
import_cmd = ( | |
kolibri_bin, | |
'manage', | |
'--skip-update', | |
'importchannel', | |
'network', | |
CHANNEL_ID, | |
) | |
run(setup_cmd, check=True, env=env) | |
run(import_cmd, check=True, env=env) | |
def importcontent(kolibri_bin, kolibri_home): | |
env = os.environ.copy() | |
env['KOLIBRI_HOME'] = kolibri_home | |
import_cmd = ( | |
kolibri_bin, | |
'manage', | |
'--skip-update', | |
'importcontent', | |
'--fail-on-error', | |
'network', | |
CHANNEL_ID, | |
) | |
run(import_cmd, check=True, env=env) | |
def setup_0_15(): | |
setup(KOLIBRI_0_15_BIN, KOLIBRI_0_15_HOME) | |
def importcontent_0_15(): | |
importcontent(KOLIBRI_0_15_BIN, KOLIBRI_0_15_HOME) | |
def setup_0_16_a12(): | |
setup(KOLIBRI_0_16_A12_BIN, KOLIBRI_0_16_A12_HOME) | |
def importcontent_0_16_a12(): | |
importcontent(KOLIBRI_0_16_A12_BIN, KOLIBRI_0_16_A12_HOME) | |
def setup_0_16_a15(): | |
setup(KOLIBRI_0_16_A15_BIN, KOLIBRI_0_16_A15_HOME) | |
def importcontent_0_16_a15(): | |
importcontent(KOLIBRI_0_16_A15_BIN, KOLIBRI_0_16_A15_HOME) | |
def main(): | |
times_0_15 = repeat( | |
stmt=importcontent_0_15, | |
setup=setup_0_15, | |
number=1, | |
repeat=5, | |
) | |
times_0_16_a12 = repeat( | |
stmt=importcontent_0_16_a12, | |
setup=setup_0_16_a12, | |
number=1, | |
repeat=5, | |
) | |
times_0_16_a15 = repeat( | |
stmt=importcontent_0_16_a15, | |
setup=setup_0_16_a15, | |
number=1, | |
repeat=5, | |
) | |
print(f'Min 0.15 time {min(times_0_15)} seconds') | |
print(f'Min 0.16.0a12 time {min(times_0_16_a12)} seconds') | |
print(f'Min 0.16.0a15 time {min(times_0_16_a15)} seconds') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment