|
|
@@ -1,13 +1,15 @@
|
|
|
import argparse
|
|
|
import csv
|
|
|
+import re
|
|
|
+import subprocess
|
|
|
import sys
|
|
|
import time
|
|
|
|
|
|
sys.setrecursionlimit(10000)
|
|
|
|
|
|
XDEVS_PYTHON_CMD = ""
|
|
|
-XDEVS_JAVA_CMD = "java -classpath simulators/xdevs-java/out/production/xdevs xdevs.core.devstone.DEVStone {model_type} {depth} {width} {int_delay} {ext_delay} chained false"
|
|
|
-XDEVS_JAVA_CHAINED_CMD = "java -classpath simulators/xdevs-java/out/production/xdevs xdevs.core.devstone.DEVStone {model_type} {depth} {width} {int_delay} {ext_delay} coord false"
|
|
|
+XDEVS_JAVA_CMD = "java -classpath simulators/xdevs-java/out/production/xdevs xdevs.core.devstone.DEVStone {model_type} {depth} {width} {int_cycles} {ext_cycles} chained false"
|
|
|
+XDEVS_JAVA_CHAINED_CMD = "java -classpath simulators/xdevs-java/out/production/xdevs xdevs.core.devstone.DEVStone {model_type} {depth} {width} {int_cycles} {ext_cycles} coord false"
|
|
|
PYPDEVS_CMD = ""
|
|
|
PYPDEVS_MIN_CMD = ""
|
|
|
CADMIUM_CMD = ""
|
|
|
@@ -20,6 +22,9 @@ DEFAULT_MODEL_TYPES = ("LI", "HI", "HO", "HOmod")
|
|
|
DEFAULT_MAX_TIME = 1e10
|
|
|
DEFAULT_NUM_REPS = 10
|
|
|
|
|
|
+RE_SIM_TIMES = r"Model creation time: ?([0-9.e-]+) ?.*Engine set ?up time: ?([0-9.e-]+) ?.*Simulation time: ?([0-9.e-]+)"
|
|
|
+
|
|
|
+
|
|
|
engines = {"xdevs-python": XDEVS_PYTHON_CMD,
|
|
|
"xdevs-java": XDEVS_JAVA_CMD,
|
|
|
"xdevs-java-chained": XDEVS_JAVA_CHAINED_CMD,
|
|
|
@@ -64,12 +69,15 @@ def parse_args():
|
|
|
args.params = DEFAULT_PARAMS
|
|
|
|
|
|
if args.include_engines:
|
|
|
- args.include_engines = [x.split() for x in args.include_engines.split(",")]
|
|
|
+ args.include_engines = args.include_engines.split(",")
|
|
|
+ for engine in args.include_engines:
|
|
|
+ if engine not in engines:
|
|
|
+ raise RuntimeError("%s is not in the engines list" % engine)
|
|
|
else:
|
|
|
args.include_engines = engines.keys()
|
|
|
|
|
|
if args.exclude_engines:
|
|
|
- excluded = [x.split() for x in args.exclude_engines.split(",")]
|
|
|
+ excluded = args.exclude_engines.split(",")
|
|
|
args.include_engines = [x for x in args.include_engines if x not in excluded]
|
|
|
|
|
|
if not args.num_rep:
|
|
|
@@ -91,12 +99,27 @@ with open(args.out_file, "w") as csv_file:
|
|
|
csv_writer.writerow(("engine", "iter", "model", "depth", "width", "model_time", "runner_time", "sim_time", "total_time"))
|
|
|
|
|
|
for engine in args.include_engines:
|
|
|
+ engine_cmd = engines[engine]
|
|
|
+
|
|
|
for model_type in args.model_types:
|
|
|
- for depth, width, int_delay, ext_delay in args.params:
|
|
|
+ for depth, width, int_cycles, ext_cycles in args.params:
|
|
|
+ engine_cmd_f = engine_cmd.format(model_type=model_type, depth=depth, width=width, int_cycles=int_cycles, ext_cycles=ext_cycles)
|
|
|
for i_exec in range(args.num_rep):
|
|
|
- print(engine, i_exec, model_type, depth, width)
|
|
|
+ print(engine_cmd_f)
|
|
|
+
|
|
|
# Open subprocess
|
|
|
- # Read output
|
|
|
- # Extract data
|
|
|
+ result = subprocess.run(engine_cmd_f.split(), stdout=subprocess.PIPE)
|
|
|
+
|
|
|
+ # Read data from output
|
|
|
+ found = re.search(RE_SIM_TIMES, str(result.stdout))
|
|
|
+
|
|
|
+ if not found:
|
|
|
+ print(result.stdout)
|
|
|
+ raise RuntimeError("Simulation execution times could not be extracted.")
|
|
|
+
|
|
|
+ model_time, engine_time, sim_time = tuple(map(float, found.groups()))
|
|
|
+ total_time = sum((model_time, engine_time, sim_time))
|
|
|
+
|
|
|
# Write results into output file
|
|
|
- # csv_writer.writerow(curr_row)
|
|
|
+ row = (engine, i_exec, model_type, depth, width, int_cycles, ext_cycles, model_time, engine_time, sim_time, total_time)
|
|
|
+ csv_writer.writerow(row)
|