-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot.py
More file actions
127 lines (94 loc) · 3.47 KB
/
Copy pathboot.py
File metadata and controls
127 lines (94 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
from plot import *
# DIVIDING FACTOR
# 2_000_000 for the vf2
# 200_000 for the premier
# Read CSV
csv = pd.read_csv(f"boot/{HARDWARE}.csv")
# Remove 'Firmware exit' column
csv = csv.drop('Firmware exit', axis=1)
# Move other column at the end
csv["IPI"] = csv.pop("IPI")
csv["Other"] = csv.pop("Other")
print(csv)
if HARDWARE == "premier":
csv = csv.groupby(csv.index // 4).sum()
print("Firmware traps/s: ", csv["Other"][140:].mean())
print("Total traps/s: ", csv[140:].mean().sum())
print("Total traps/s: ", csv[140:].mean())
# Normalize each row to sum to 1
csv = csv.apply(lambda row: row / row.sum() if row.sum() > 0 else row, axis=1)
# Truncate data
# print(len(csv))
# csv = csv.head(200)
# print(len(csv))
# Prepare data
data = {}
for col in csv.columns:
data[col] = np.array(csv[col])
unit_of_time = np.arange(0, len(csv), 1)
fig, ax = plt.subplots()
fig.set_figheight(3.2)
fig.set_figwidth(5.4)
# Convert unit_of_time to labels (every 2 minutes)
unit_of_time_labels = list(map(lambda x: f"{x // 2}s", unit_of_time))
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']
blue = colors[0]
colors = colors[1:]
colors[5] = blue
print(blue)
print(colors)
# Compute cumulative sums for stacking
stacked_values = np.zeros_like(unit_of_time, dtype=float)
for i, (label, values) in enumerate(data.items()):
ax.fill_between(unit_of_time, stacked_values, stacked_values + values,
step="post", label=label, alpha=0.8, color = colors[i], edgecolor=None)
stacked_values += values # Stack values
# Set x-axis ticks
ax.set_xticks(unit_of_time[::50])
ax.set_xticklabels(unit_of_time_labels[::50], fontsize=11.2)
# Labels and formatting
# ax.set_title(f"Proportion of exceptions per category on the {HARDWARE}")
# ax.set_xlabel('CPU cycles')
ax.set_ylabel('Proportion of traps', fontsize=11.2)
ax.set_ylim(0, 1)
ax.set_xlim(0, 180) # max is 256
# Vertical reference line
# ax.axvline(x=113, color='black', linestyle='--')
# Minor ticks for y-axis
ax.yaxis.set_minor_locator(mticker.MultipleLocator(.2))
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset
# Define zoom area (e.g., first 20 CPU cycles)
x1, x2 = 18, 30
y1, y2 = 0.96, 1.00 # Zoom sur toute la hauteur
if HARDWARE == "premier":
x1, x2 = 45, 55
y1, y2 = 0, 0.015
# Create inset
if HARDWARE == "premier":
axins = zoomed_inset_axes(ax, zoom=9, loc="right")
else:
axins = zoomed_inset_axes(ax, zoom=10.5, loc="lower right") # Facteur de zoom ajustable
# Replot same data in inset
stacked_values_zoom = np.zeros_like(unit_of_time[:x2], dtype=float)
i = 0
for label, values in data.items():
axins.fill_between(unit_of_time[:x2], stacked_values_zoom, stacked_values_zoom + values[:x2], step="post", alpha=0.8, color = colors[i], edgecolor=None)
stacked_values_zoom += values[:x2]
i += 1
# Format inset
axins.set_xlim(x1, x2-4)
axins.set_ylim(y1, y2)
axins.set_xticks([]) # Enlever les ticks pour plus de lisibilité
axins.set_yticks([])
# Draw rectangle on main plot
mark_inset(ax, axins, loc1=1, loc2=3, fc="none", ec="black", linestyle="-")
# Place legend outside the plot
ax.legend(loc="lower center", bbox_to_anchor=(0.45, -0.32), fancybox=False, ncol=3, labelspacing=-0.06, columnspacing=0.6, frameon=False, fontsize=10.7)
# Adjust layout for better spacing
plt.tight_layout()
# Save as PDF
plt.savefig(f"plots/boot_{HARDWARE}.pdf", format="pdf")