ds: add ctf mode analysis
This commit is contained in:
parent
968accd552
commit
56c625bfe4
23
garlic/ds/ctf/mode.nix
Normal file
23
garlic/ds/ctf/mode.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
stdenv
|
||||
, python3
|
||||
, gzip
|
||||
}:
|
||||
|
||||
resultTree:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "ctf-mode.json.gz";
|
||||
preferLocalBuild = true;
|
||||
src = ./mode.py;
|
||||
phases = [ "unpackPhase" "installPhase" ];
|
||||
|
||||
unpackPhase = ''
|
||||
cp $src mode.py
|
||||
'';
|
||||
|
||||
buildInputs = [ python3 gzip ];
|
||||
installPhase = ''
|
||||
python mode.py ${resultTree} | gzip > $out
|
||||
'';
|
||||
}
|
83
garlic/ds/ctf/mode.py
Normal file
83
garlic/ds/ctf/mode.py
Normal file
@ -0,0 +1,83 @@
|
||||
import json, re, sys, os, glob
|
||||
from os import path
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, flush=True, **kwargs)
|
||||
|
||||
def process_run(tree, runPath):
|
||||
|
||||
ctf_mode = {}
|
||||
|
||||
with open(".garlic/time_mode_runtime.csv", "r") as f:
|
||||
ctf_mode['runtime'] = float(f.readline())
|
||||
|
||||
with open(".garlic/time_mode_dead.csv", "r") as f:
|
||||
ctf_mode['dead'] = float(f.readline())
|
||||
|
||||
with open(".garlic/time_mode_task.csv", "r") as f:
|
||||
ctf_mode['task'] = float(f.readline())
|
||||
|
||||
tree['ctf_mode'] = ctf_mode
|
||||
|
||||
with open("stdout.log", "r") as f:
|
||||
lines = [line.strip() for line in f.readlines()]
|
||||
|
||||
time_line = None
|
||||
for line in lines:
|
||||
|
||||
if re.match(r'^ ?time .*', line):
|
||||
time_line = line
|
||||
break
|
||||
|
||||
if time_line is None:
|
||||
eprint("missing time line, aborting")
|
||||
eprint("stdout file = {}/stdout.log".format(runPath))
|
||||
exit(1)
|
||||
|
||||
time_str = time_line.split()[1]
|
||||
|
||||
tree['time'] = float(time_str)
|
||||
|
||||
print(json.dumps(tree))
|
||||
|
||||
def process_result_tree(resultTree):
|
||||
|
||||
eprint("processing resultTree: " + resultTree)
|
||||
|
||||
os.chdir(resultTree)
|
||||
|
||||
experiments = glob.glob(resultTree + "/*-experiment")
|
||||
|
||||
for exp in glob.glob("*-experiment"):
|
||||
eprint("found experiment: " + exp)
|
||||
expPath = path.join(resultTree, exp)
|
||||
os.chdir(expPath)
|
||||
|
||||
for unit in glob.glob("*-unit"):
|
||||
eprint("found unit: " + unit)
|
||||
unitPath = path.join(resultTree, exp, unit)
|
||||
os.chdir(unitPath)
|
||||
|
||||
with open('garlic_config.json') as json_file:
|
||||
garlic_conf = json.load(json_file)
|
||||
|
||||
tree = {"exp":exp, "unit":unit, "config":garlic_conf}
|
||||
|
||||
for i in range(garlic_conf['loops']):
|
||||
run = str(i + 1)
|
||||
runPath = path.join(resultTree, exp, unit, run)
|
||||
if path.isdir(runPath) == False:
|
||||
eprint("missing run {}, aborting".format(run))
|
||||
exit(1)
|
||||
|
||||
tree["run"] = run
|
||||
os.chdir(runPath)
|
||||
|
||||
process_run(tree, runPath)
|
||||
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
eprint("usage: python {} <resultTree>".format(argv[0]))
|
||||
exit(1)
|
||||
|
||||
process_result_tree(sys.argv[1])
|
@ -17,4 +17,6 @@
|
||||
};
|
||||
|
||||
perf.stat = callPackage ./perf/stat.nix {};
|
||||
|
||||
ctf.mode = callPackage ./ctf/mode.nix {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user