Reduce lists of temps in CPU graph
This helps highlight the changes from low and high CPU loads.
This commit is contained in:
parent
1ede6ad93b
commit
eb07a93e20
1 changed files with 36 additions and 10 deletions
|
|
@ -45,6 +45,23 @@ THRESH_GREAT = 750 * 1024**2
|
||||||
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
def reduce_cpu_temp_list(list_of_temps, factor=5, start=30) -> list[float]:
|
||||||
|
"""Reduce temperature list by averaging adjacent values.
|
||||||
|
|
||||||
|
NOTE: This only averages values after the amount defined by start.
|
||||||
|
NOTE 2: If the last group is less than the factor it is simply dropped.
|
||||||
|
"""
|
||||||
|
new_list = list_of_temps[:start]
|
||||||
|
list_of_temps = list_of_temps[start:]
|
||||||
|
while list_of_temps:
|
||||||
|
group = list_of_temps[:factor]
|
||||||
|
list_of_temps = list_of_temps[factor:]
|
||||||
|
if len(group) < factor:
|
||||||
|
continue
|
||||||
|
new_list.append(sum(group)/factor)
|
||||||
|
return new_list
|
||||||
|
|
||||||
|
|
||||||
def export_cpu_graph(cpu_description, log_dir, sensor_history):
|
def export_cpu_graph(cpu_description, log_dir, sensor_history):
|
||||||
"""Exports PNG graph using matplotlib."""
|
"""Exports PNG graph using matplotlib."""
|
||||||
lines = {}
|
lines = {}
|
||||||
|
|
@ -66,6 +83,8 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history):
|
||||||
for adapter in sensor_data.get('CPUTemps', {}).values():
|
for adapter in sensor_data.get('CPUTemps', {}).values():
|
||||||
for source, data in adapter.items():
|
for source, data in adapter.items():
|
||||||
y_values = data['Temps']
|
y_values = data['Temps']
|
||||||
|
if run_label in ('Sysbench', 'Prime95'):
|
||||||
|
y_values = reduce_cpu_temp_list(y_values)
|
||||||
all_run_temps.extend(y_values)
|
all_run_temps.extend(y_values)
|
||||||
run_length = max(run_length, len(y_values))
|
run_length = max(run_length, len(y_values))
|
||||||
if source not in lines:
|
if source not in lines:
|
||||||
|
|
@ -89,18 +108,25 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history):
|
||||||
layout='constrained',
|
layout='constrained',
|
||||||
)
|
)
|
||||||
ax.set_title(cpu_description)
|
ax.set_title(cpu_description)
|
||||||
|
ax.set_xticks([])
|
||||||
for label, data in lines.items():
|
for label, data in lines.items():
|
||||||
ax.plot(data, label=label)
|
ax.plot(data, label=label)
|
||||||
#prev_label = 'Idle' # Always skip Idle
|
#prev_label = 'Idle' # Always skip Idle
|
||||||
#for offset, label in offset_labels:
|
prev_label = ''
|
||||||
# if label == prev_label:
|
for offset, label in offset_labels:
|
||||||
# continue
|
color = 'grey'
|
||||||
# color = 'r' if label in ('Prime95', 'Sysbench') else 'b'
|
if label == prev_label:
|
||||||
# if label == 'Cooldown':
|
continue
|
||||||
# label = ''
|
if label == 'Sysbench':
|
||||||
# ax.axvline(x=offset, color=color, label=label)
|
color = 'orange'
|
||||||
# #ax.axvline(x=offset, color=color)
|
if label == 'Prime95':
|
||||||
# prev_label = label
|
color = 'red'
|
||||||
|
if label == 'Cooldown':
|
||||||
|
color = 'blue'
|
||||||
|
label = ''
|
||||||
|
ax.axvline(x=offset, color=color, label=label, linestyle='--')
|
||||||
|
#ax.axvline(x=offset, color=color)
|
||||||
|
prev_label = label
|
||||||
for run_label, data in run_averages.items():
|
for run_label, data in run_averages.items():
|
||||||
if run_label not in ('Prime95', 'Sysbench'):
|
if run_label not in ('Prime95', 'Sysbench'):
|
||||||
continue
|
continue
|
||||||
|
|
@ -108,7 +134,7 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history):
|
||||||
y = data['Temp'],
|
y = data['Temp'],
|
||||||
color = 'orange' if run_label == 'Sysbench' else 'red',
|
color = 'orange' if run_label == 'Sysbench' else 'red',
|
||||||
label = f'{run_label} (Avg)',
|
label = f'{run_label} (Avg)',
|
||||||
linestyle = '--',
|
linestyle = ':',
|
||||||
)
|
)
|
||||||
ax.legend()
|
ax.legend()
|
||||||
pyplot.savefig(out_path)
|
pyplot.savefig(out_path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue