diff --git a/scripts/wk/graph.py b/scripts/wk/graph.py index 91ade848..7d1505fd 100644 --- a/scripts/wk/graph.py +++ b/scripts/wk/graph.py @@ -45,6 +45,23 @@ THRESH_GREAT = 750 * 1024**2 # 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): """Exports PNG graph using matplotlib.""" lines = {} @@ -66,6 +83,8 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history): for adapter in sensor_data.get('CPUTemps', {}).values(): for source, data in adapter.items(): y_values = data['Temps'] + if run_label in ('Sysbench', 'Prime95'): + y_values = reduce_cpu_temp_list(y_values) all_run_temps.extend(y_values) run_length = max(run_length, len(y_values)) if source not in lines: @@ -89,18 +108,25 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history): layout='constrained', ) ax.set_title(cpu_description) + ax.set_xticks([]) for label, data in lines.items(): ax.plot(data, label=label) #prev_label = 'Idle' # Always skip Idle - #for offset, label in offset_labels: - # if label == prev_label: - # continue - # color = 'r' if label in ('Prime95', 'Sysbench') else 'b' - # if label == 'Cooldown': - # label = '' - # ax.axvline(x=offset, color=color, label=label) - # #ax.axvline(x=offset, color=color) - # prev_label = label + prev_label = '' + for offset, label in offset_labels: + color = 'grey' + if label == prev_label: + continue + if label == 'Sysbench': + color = 'orange' + if label == 'Prime95': + 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(): if run_label not in ('Prime95', 'Sysbench'): continue @@ -108,7 +134,7 @@ def export_cpu_graph(cpu_description, log_dir, sensor_history): y = data['Temp'], color = 'orange' if run_label == 'Sysbench' else 'red', label = f'{run_label} (Avg)', - linestyle = '--', + linestyle = ':', ) ax.legend() pyplot.savefig(out_path)