Skip to content

Instantly share code, notes, and snippets.

@andreacassioli
Created June 26, 2014 07:30
license overhead
import timeit
#---------- SETUP
ntests= 10000
#---------- CODE SNIPPETS
import_msk="import mosek\n"
setup_env_only="env=mosek.Env()\n"
setup_task_only="task=env.Task()\n"
solve_nothing= """\
with mosek.Env() as env:
with env.Task () as task:
task.optimize()
"""
solve_nothing_w_task= """\
with env.Task () as task:
task.optimize()
"""
#---------- RUNNIGN TESTS
print "-------------------------------------------------------------------------------------------------"
print "Running ",ntests," please wait..."
print
solve_nothing_t= timeit.timeit(stmt=solve_nothing,number=ntests,setup=import_msk)
print "avg. time for env+task+solve = ", solve_nothing_t/ntests," sec."
solve_nothing_w_task_t= timeit.timeit(stmt=solve_nothing_w_task,number=ntests,setup=import_msk+setup_env_only)
print "avg. time for task+solve for given env = ", solve_nothing_w_task_t/ntests," sec."
solve_nothing_w_task_env_t= timeit.timeit(stmt='task.optimize()',number=ntests,setup=import_msk+setup_env_only+setup_task_only)
print "avg. time for solve for given env and task = ", solve_nothing_w_task_env_t/ntests," sec."
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment