|
|
@@ -5,10 +5,6 @@ import csv
|
|
|
import re
|
|
|
from argparse import ArgumentParser, Action
|
|
|
from pathlib import Path
|
|
|
-from itertools import product
|
|
|
-from datetime import datetime
|
|
|
-
|
|
|
-from pandas.errors import ParserError
|
|
|
|
|
|
MODEL_TYPES = ("LI", "HI", "HO", "HOmod")
|
|
|
DS_MODEL_TYPES = ("LI2HI", "HI2LI", "LI-HI", "dLI", "dHI")
|
|
|
@@ -84,7 +80,7 @@ def run_devstone(model_type, depth, width, mode, out, memory, *, classic=False,
|
|
|
return None, None, None
|
|
|
|
|
|
def defaultArguments(parser):
|
|
|
- parser.add_argument("-p", "--path", type=str, default="./Results-PyPDEVS", help="Path to the results directory")
|
|
|
+ parser.add_argument("-p", "--path", type=Path, default=Path("./Results-PyPDEVS"), help="Path to the results directory")
|
|
|
parser.add_argument("-f", '--filename', type=str, default="", help="Name of the output file")
|
|
|
parser.add_argument("-a", "--append", action="store_true", help="Append to the output file instead of overwriting.")
|
|
|
|
|
|
@@ -224,37 +220,45 @@ if __name__ == "__main__":
|
|
|
"gen_mode": "uniform" if not hasattr(args, "gen_mode") else args.gen_mode,
|
|
|
"number": 1 if not hasattr(args, "number") else args.number,
|
|
|
}
|
|
|
-
|
|
|
+ time_dir = args.path / "Time"
|
|
|
+ time_dir.mkdir(parents=True, exist_ok=True)
|
|
|
+ mem_dir = args.path / "Memory"
|
|
|
+ mem_dir.mkdir(parents=True, exist_ok=True)
|
|
|
for model_type in args.model_structure:
|
|
|
- model_time_file = f"{args.path}/Time/{mode}/{model_type}"
|
|
|
- model_memory_file = f"{args.path}/Memory/{mode}/{model_type}"
|
|
|
+ time_mode = time_dir / mode
|
|
|
+ time_mode.mkdir(parents=True, exist_ok=True)
|
|
|
+ mem_mode = mem_dir / mode
|
|
|
+ mem_mode.mkdir(parents=True, exist_ok=True)
|
|
|
+
|
|
|
+ time_file = (time_mode / model_type).with_suffix(".csv")
|
|
|
+ memory_file = (mem_mode / model_type).with_suffix(".sqlite")
|
|
|
|
|
|
if args.filename:
|
|
|
suffix = f"_{args.filename}"
|
|
|
- model_time_file += suffix
|
|
|
- model_memory_file += suffix
|
|
|
+ time_file = time_file.with_stem(time_file.stem + suffix)
|
|
|
+ memory_file = memory_file.with_stem(memory_file.stem + suffix)
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- model_time_file += ".csv"
|
|
|
- model_memory_file += ".sqlite"
|
|
|
|
|
|
- mem_cmd = {"interval": args.interval, "file": model_memory_file} if args.memory else {}
|
|
|
+ mem_cmd = {"interval": args.interval, "file": memory_file} if args.memory else {}
|
|
|
|
|
|
if not args.memory:
|
|
|
file_mode = "a" if args.append else "w"
|
|
|
- write_header = not args.append or not os.path.exists(model_time_file)
|
|
|
+ write_header = not args.append or not os.path.exists(time_file)
|
|
|
|
|
|
- with open(model_time_file, file_mode, newline="") as csvfile:
|
|
|
+ with open(time_file, file_mode, newline="") as csvfile:
|
|
|
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
|
|
if write_header:
|
|
|
writer.writeheader()
|
|
|
|
|
|
run(writer, csvfile, model_type, d, w, args, mem_cmd, extra)
|
|
|
- print(f"✅ Saved timing results to {model_time_file}")
|
|
|
+ print(f"✅ Saved timing results to {time_file}")
|
|
|
else:
|
|
|
- if os.path.exists(model_memory_file) and not args.append:
|
|
|
- os.remove(model_memory_file)
|
|
|
+ if os.path.exists(memory_file) and not args.append:
|
|
|
+ os.remove(memory_file)
|
|
|
|
|
|
print("📊 Measuring memory (Timing results will not be saved)...")
|
|
|
run(None, None, model_type, d, w, args, mem_cmd, extra)
|
|
|
- print(f"✅ Saved memory database to {model_memory_file}")
|
|
|
+ print(f"✅ Saved memory database to {memory_file}")
|
|
|
|