Skip to content

Commit

Permalink
time libmamba and classic solvers
Browse files Browse the repository at this point in the history
  • Loading branch information
dholth committed Dec 2, 2022
1 parent 398d018 commit e427609
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 35 deletions.
1 change: 1 addition & 0 deletions asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"matrix": {
"req": {
"conda-package-handling": ["2.0.2"],
"conda-libmamba-solver":[],
}
},

Expand Down
160 changes: 125 additions & 35 deletions tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,90 +15,180 @@
except ImportError:
from mock import patch


def execute_conda_cmd(args):
from conda.cli import main
with patch.object(sys, 'argv', args):

with patch.object(sys, "argv", args):
return main()


def random_env_name(N=10):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))
return "".join(
random.choice(string.ascii_uppercase + string.digits) for _ in range(N)
)


CLEAN_INDEX_ARGS = ["conda", "clean", "-iy"]
CREATE_ARGS = ["conda", "create"]
SOLVE_ARGS = CREATE_ARGS + ["--dry-run", "-n", random_env_name()]
SOLVER_DEFAULT = "classic"


def paramaterize_solver(test):
"""
Add asv test parameters to function.
"""
test.params = ["classic", "libmamba"]
return test

CLEAN_INDEX_ARGS = ['conda', 'clean', '-iy']
CREATE_ARGS = ['conda', 'create']
SOLVE_ARGS = CREATE_ARGS + ['--dry-run', '-n', random_env_name()]

thisdir = os.path.dirname(__file__)
repos_dir = os.path.join(os.path.dirname(thisdir), 'repos')
repos_dir = os.path.join(os.path.dirname(thisdir), "repos")


def channel_url(name):
return '/'.join(['file:/', repos_dir, name])
return "/".join(["file:/", repos_dir, name])


main = channel_url('main')
free = channel_url('free')
r = channel_url('r')
conda_forge = channel_url('conda-forge')
bioconda = channel_url('bioconda')
main = channel_url("main")
free = channel_url("free")
r = channel_url("r")
conda_forge = channel_url("conda-forge")
bioconda = channel_url("bioconda")


@pytest.mark.benchmark
def test_solve_anaconda_53():
@paramaterize_solver
def test_solve_anaconda_53(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(SOLVE_ARGS + ['-c', main, 'anaconda=5.3.0'])
execute_conda_cmd(SOLVE_ARGS + [f"--solver={solver}", "-c", main, "anaconda=5.3.0"])


@pytest.mark.benchmark
def test_solve_anaconda_44():
@paramaterize_solver
def test_solve_anaconda_44(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(SOLVE_ARGS + ['-c', main, '-c', free, 'anaconda=4.4.0'])
execute_conda_cmd(
SOLVE_ARGS + [f"--solver={solver}", "-c", main, "-c", free, "anaconda=4.4.0"]
)


@pytest.mark.benchmark
def test_solve_anaconda_44_free_only():
@paramaterize_solver
def test_solve_anaconda_44_free_only(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(SOLVE_ARGS + ['-c', free, 'anaconda=4.4.0'])
execute_conda_cmd(SOLVE_ARGS + [f"--solver={solver}", "-c", free, "anaconda=4.4.0"])


@pytest.mark.benchmark
def test_solve_r_essentials_r_base_defaults():
@paramaterize_solver
def test_solve_r_essentials_r_base_defaults(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(SOLVE_ARGS + ['-c', main, '-c', r, 'r-essentials', 'r-base'])
execute_conda_cmd(
SOLVE_ARGS
+ [f"--solver={solver}", "-c", main, "-c", r, "r-essentials", "r-base"]
)


@pytest.mark.benchmark
def test_solve_r_essentials_r_base_conda_forge():
@paramaterize_solver
def test_solve_r_essentials_r_base_conda_forge(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(SOLVE_ARGS + ['-c', conda_forge, '-c', main, '-c', r,
'r-essentials', 'r-base'])


#@pytest.mark.benchmark
#def test_solve_r_essentials_r_base_conda_forge_bioconda():
execute_conda_cmd(
SOLVE_ARGS
+ [
f"--solver={solver}",
"-c",
conda_forge,
"-c",
main,
"-c",
r,
"r-essentials",
"r-base",
]
)


# @pytest.mark.benchmark
# def test_solve_r_essentials_r_base_conda_forge_bioconda():
# execute_conda_cmd(CLEAN_INDEX_ARGS)
# execute_conda_cmd(SOLVE_ARGS + ['-c', bioconda, '-c', conda_forge, '-c', main, '-c', r,
# 'r-essentials', 'r-base'])


@pytest.mark.benchmark
def test_create_python():
@paramaterize_solver
def test_create_python(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(CREATE_ARGS + ['-y', '-n', random_env_name(), '-c', main, 'python=3.6'])
execute_conda_cmd(
CREATE_ARGS
+ [
f"--solver={solver}",
"-y",
"-n",
random_env_name(),
"-c",
main,
"python=3.6",
]
)


@pytest.mark.benchmark
def test_create_python_boost():
@paramaterize_solver
def test_create_python_boost(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(CREATE_ARGS + ['-y', '-n', random_env_name(), '-c', main, 'python=3.6', 'libboost'])
execute_conda_cmd(
CREATE_ARGS
+ [
f"--solver={solver}",
"-y",
"-n",
random_env_name(),
"-c",
main,
"python=3.6",
"libboost",
]
)


@pytest.mark.benchmark
def test_create_numpy_openblas():
@paramaterize_solver
def test_create_numpy_openblas(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(CREATE_ARGS + ['-y', '-n', random_env_name(), '-c', main, 'python=3.6', 'numpy=1.15.2', 'nomkl'])
execute_conda_cmd(
CREATE_ARGS
+ [
f"--solver={solver}",
"-y",
"-n",
random_env_name(),
"-c",
main,
"python=3.6",
"numpy=1.15.2",
"nomkl",
]
)


@pytest.mark.benchmark
def test_create_numpy_mkl():
@paramaterize_solver
def test_create_numpy_mkl(solver=SOLVER_DEFAULT):
execute_conda_cmd(CLEAN_INDEX_ARGS)
execute_conda_cmd(CREATE_ARGS + ['-y', '-n', random_env_name(), '-c', main, 'python=3.6', 'numpy=1.15.2'])
execute_conda_cmd(
CREATE_ARGS
+ [
f"--solver={solver}",
"-y",
"-n",
random_env_name(),
"-c",
main,
"python=3.6",
"numpy=1.15.2",
]
)

0 comments on commit e427609

Please sign in to comment.