From d26d4b6c180bf127c381a5212153b51d7a5c0dc1 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Tue, 5 Jan 2016 17:00:55 +0100 Subject: [PATCH] Added task to prepare dstat output for usage. - added parameter timeout for sol --- fabfile.py | 2 ++ ilp_measurement.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fabfile.py b/fabfile.py index c171bb8..2ef6ff3 100644 --- a/fabfile.py +++ b/fabfile.py @@ -35,6 +35,8 @@ def cloc(not_match, *args, **kwargs): @task @hosts('rschoene@141.76.65.177') def dl(name, rdir = '~/git/racr-mquat/'): + """ Download a single file from the remote host. + Arguments: name, [absolute-remote-directory] """ #run('uname -a') target = os.path.join(rdir, name) print target diff --git a/ilp_measurement.py b/ilp_measurement.py index 6a99f85..f9d55c5 100644 --- a/ilp_measurement.py +++ b/ilp_measurement.py @@ -104,15 +104,24 @@ def dstat_log(directory): return 'profiling/{}/dstat.log'.format(directory) def dirname(d): return os.path.split(os.path.dirname(d))[-1] +@task +def prepare_dstat(f): + newFile = f.replace('.log', '.csv') + schema = ['time'] + [cpu+t for t in ("usr","sys","idl","wai","hiq","siq") for cpu in ("total","cpu0","cpu1","cpu2","cpu3")] + \ + ["1m","5m","15m","used","buff","cach","free","read","writ"] + with open(newFile, 'w') as fd: + fd.write(",".join(schema)) + local_quiet('grep -Ev ^\\" {0} >> {1}'.format(f,newFile)) + @task(name = 'sol') -def sol(number = 1, solver = 'glpsol', pathname = '*', skip_conflate = False): +def sol(number = 1, solver = 'glpsol', pathname = '*', skip_conflate = False, timeout = 40): """ Run solver n times (default: once) """ - do_sol(solver, int(number), pathname, skip_conflate) + do_sol(solver, int(number), pathname, skip_conflate, int(timeout)) -params = { 'glpsol' : ['glpsol --tmlim 40 --lp {lp} -w {sol}', 'INTEGER OPTIMAL SOLUTION FOUND', 'Time used:[\s]*(.*?) secs', '(\d+) rows, (\d+) columns, (\d+) non-zeros'], +params = { 'glpsol' : ['glpsol --tmlim {timeout} --lp {lp} -w {sol}', 'INTEGER OPTIMAL SOLUTION FOUND', 'Time used:[\s]*(.*?) secs', '(\d+) rows, (\d+) columns, (\d+) non-zeros'], 'gurobi' : ['gurobi_cl ResultFile={sol} {lp}', 'Optimal solution found', 'in (.*?) seconds', 'Optimize a model with (\d+) rows, (\d+) columns and (\d+) nonzeros']} -def do_sol(solver, number, pathname, skip_conflate): +def do_sol(solver, number, pathname, skip_conflate, timeout): assertTrue = utils.assertTrueContinue old_cd = os.getcwd() dirs = glob('profiling/{0}/'.format(pathname)) @@ -142,7 +151,7 @@ def do_sol(solver, number, pathname, skip_conflate): if not ilp.endswith('.lp'): continue start = timeit.default_timer() - out = local_quiet(params[solver][0].format(lp = ilp, sol = ilp.replace('lp','sol'))) + out = local_quiet(params[solver][0].format(lp = ilp, sol = ilp.replace('lp','sol'), timeout = timeout)) stop = timeit.default_timer() today = datetime.today() if re.search(params[solver][1], out): -- GitLab