|
|
@@ -16,8 +16,7 @@ SIMULATOR_MAPPING = {
|
|
|
"parallel": "(p)",
|
|
|
"dynamic": "(d)",
|
|
|
"dynamic-classic": "(dc)",
|
|
|
- "Memory": "(a)",
|
|
|
- "Agents": "(a)",
|
|
|
+ "Memory": "(A)",
|
|
|
}
|
|
|
|
|
|
TIME_UNITS = {"ms": 0.001, "s": 1, "m": 60, "h": 3600}
|
|
|
@@ -26,6 +25,32 @@ MEMORY_UNITS = {
|
|
|
"KiB": 1024, "MiB": 1024 ** 2, "GiB": 1024 ** 3
|
|
|
}
|
|
|
|
|
|
+PREDEFINED_STYLES = {
|
|
|
+ 'blue': {'color': 'tab:blue', 'ls': '-', 'marker': 'o'},
|
|
|
+ 'orange': {'color': 'tab:orange', 'ls': '--', 'marker': 's'},
|
|
|
+ 'green': {'color': 'tab:green', 'ls': '-.', 'marker': '^'},
|
|
|
+ 'red': {'color': 'tab:red', 'ls': ':', 'marker': 'D'},
|
|
|
+ 'purple': {'color': 'tab:purple', 'ls': '-', 'marker': 'v'},
|
|
|
+ 'brown': {'color': 'tab:brown', 'ls': '--', 'marker': 'X'},
|
|
|
+}
|
|
|
+
|
|
|
+SHORTHANDS = {
|
|
|
+ 'b': 'blue',
|
|
|
+ 'o': 'orange',
|
|
|
+ 'g': 'green',
|
|
|
+ 'r': 'red',
|
|
|
+ 'p': 'purple',
|
|
|
+ 'br': 'brown'
|
|
|
+}
|
|
|
+STYLE_KEYS = list(PREDEFINED_STYLES.keys())
|
|
|
+VALID_STYLE_INPUTS = list(PREDEFINED_STYLES.keys()) + list(SHORTHANDS.keys())
|
|
|
+
|
|
|
+def get_style_config(user_input):
|
|
|
+ '''Helper to resolve shorthands and handle case-insensitivity.'''
|
|
|
+ normalized = user_input.lower()
|
|
|
+ key = SHORTHANDS.get(normalized, normalized)
|
|
|
+ return PREDEFINED_STYLES.get(key, PREDEFINED_STYLES['blue'])
|
|
|
+
|
|
|
|
|
|
def normalize_database(db_path):
|
|
|
"""Normalizes the database so that every process starts at 0 RSS (Net Growth)."""
|
|
|
@@ -74,13 +99,13 @@ def process_data(df, mem_unit, time_unit):
|
|
|
return df
|
|
|
|
|
|
|
|
|
-def plot_traces(files, width=None, depth=None, mem_unit="MB", time_unit="s", path="", name="", title=None, bw=False):
|
|
|
+def plot_traces(files, styles, width=None, depth=None, mem_unit="MB", time_unit="s", path="", name="", title=None, bw=False):
|
|
|
plt.figure(figsize=(10, 6))
|
|
|
style_cycle = cycle(zip(cycle(plt.rcParams['axes.prop_cycle'].by_key()['color'] if not bw else ['black']),
|
|
|
cycle(['-', '--', '-.', ':'])))
|
|
|
plotted_any, models, main_model_type = False, [], None
|
|
|
|
|
|
- for db_file in files:
|
|
|
+ for i, db_file in enumerate(files):
|
|
|
file = Path(db_file).resolve()
|
|
|
df = get_memory_trace(file)
|
|
|
if df is None: continue
|
|
|
@@ -90,8 +115,18 @@ def plot_traces(files, width=None, depth=None, mem_unit="MB", time_unit="s", pat
|
|
|
if main_model_type is None: main_model_type = model_type
|
|
|
df = process_data(df, mem_unit, time_unit)
|
|
|
color, linestyle = next(style_cycle)
|
|
|
+
|
|
|
+ style_input = styles[i] if i < len(styles) else STYLE_KEYS[i % len(STYLE_KEYS)]
|
|
|
+ style = get_style_config(style_input)
|
|
|
label = f"{model_type} {SIMULATOR_MAPPING.get(file.parent.name, f'({file.parent.name})')}"
|
|
|
- plt.plot(df["relative_time"], df["memory"], label=label, color=color, linestyle=linestyle, linewidth=1.5)
|
|
|
+ plt.plot(
|
|
|
+ df["relative_time"],
|
|
|
+ df["memory"],
|
|
|
+ label=label,
|
|
|
+ color=style['color'],
|
|
|
+ linestyle=style['ls'],
|
|
|
+ linewidth=1.5
|
|
|
+ )
|
|
|
plotted_any = True
|
|
|
|
|
|
if not plotted_any: return
|
|
|
@@ -99,15 +134,18 @@ def plot_traces(files, width=None, depth=None, mem_unit="MB", time_unit="s", pat
|
|
|
plt.xlabel(f"Time ({time_unit})");
|
|
|
plt.ylabel(f"Resident Set Size Net Growth ({mem_unit})")
|
|
|
|
|
|
- if main_model_type and width and depth:
|
|
|
- props = model_properties(main_model_type, width, depth)
|
|
|
- atomics = int(props.get("Atomic Models", 0))
|
|
|
- events = int(props.get("Events", 0))
|
|
|
+ if not title:
|
|
|
+ if main_model_type and width and depth:
|
|
|
+ props = model_properties(main_model_type, width, depth)
|
|
|
+ atomics = int(props.get("Atomic Models", 0))
|
|
|
+ events = int(props.get("Events", 0))
|
|
|
|
|
|
- plt.suptitle(f"Memory Usage over Time (Net Growth): {main_model_type}", fontsize=12)
|
|
|
- plt.title(f"Width: {width}, Depth: {depth} | #Atomic Models: {atomics:,} | #Events: {events:,}", fontsize=10)
|
|
|
+ plt.suptitle(f"Memory Usage over Time (Net Growth): {main_model_type}", fontsize=12)
|
|
|
+ plt.title(f"Width: {width}, Depth: {depth} | #Atomic Models: {atomics:,} | #Events: {events:,}", fontsize=10)
|
|
|
+ else:
|
|
|
+ plt.title("Memory Usage over Time (Net Growth)", fontsize=12)
|
|
|
else:
|
|
|
- plt.title("Memory Usage over Time (Net Growth)", fontsize=12)
|
|
|
+ plt.title(title, fontsize=12)
|
|
|
|
|
|
plt.legend()
|
|
|
plt.grid(True, linestyle=':', alpha=0.6)
|
|
|
@@ -123,6 +161,7 @@ def main():
|
|
|
parser.add_argument("files", nargs="+")
|
|
|
parser.add_argument("-w", "--width", type=int)
|
|
|
parser.add_argument("-d", "--depth", type=int)
|
|
|
+ parser.add_argument('-s', '--styles', type=str, nargs='+', help=f"Space-separated list of colors matching CSV order. Options: {', '.join(VALID_STYLE_INPUTS)}")
|
|
|
parser.add_argument("-mu", "--memory-unit", default="MB")
|
|
|
parser.add_argument("-tu", "--time-unit", default="s")
|
|
|
parser.add_argument("-p", "--path", default="")
|
|
|
@@ -130,7 +169,13 @@ def main():
|
|
|
parser.add_argument("-t", "--title")
|
|
|
parser.add_argument("--bw", action="store_true")
|
|
|
args = parser.parse_args()
|
|
|
- plot_traces(args.files, args.width, args.depth, args.memory_unit, args.time_unit, args.path, args.name, args.title,
|
|
|
+
|
|
|
+ if not args.styles:
|
|
|
+ styles = [STYLE_KEYS[i % len(STYLE_KEYS)] for i in range(len(args.files))]
|
|
|
+ else:
|
|
|
+ styles = args.styles
|
|
|
+
|
|
|
+ plot_traces(args.files, styles, args.width, args.depth, args.memory_unit, args.time_unit, args.path, args.name, args.title,
|
|
|
args.bw)
|
|
|
|
|
|
|