Commit 7aa27106 authored by Joanne Hugé's avatar Joanne Hugé

Add legends to the graphs

parent a90394e5
...@@ -82,7 +82,7 @@ class MeasureSetHandler: ...@@ -82,7 +82,7 @@ class MeasureSetHandler:
self.remove_measure_set(mtype, mid) self.remove_measure_set(mtype, mid)
print("Removed all measures") print("Removed all measures")
def generate_graphs(self): def generate_graphs(self, metadata_masks):
# List of colors to use to superimpose the different plots # List of colors to use to superimpose the different plots
colors = ['red', 'blue', 'green', 'purple', 'yellow'] colors = ['red', 'blue', 'green', 'purple', 'yellow']
...@@ -106,15 +106,22 @@ class MeasureSetHandler: ...@@ -106,15 +106,22 @@ class MeasureSetHandler:
for i in range(nb_props): for i in range(nb_props):
prop_name = measures[0].props_names[i] prop_name = measures[0].props_names[i]
subplots = []
metadata_infos = []
# Superimpose all the different measures of the same type and property type # Superimpose all the different measures of the same type and property type
for j, mid in enumerate(self.measure_sets[mtype]['ids']): for j, mid in enumerate(self.measure_sets[mtype]['ids']):
measure = self.get_measure_set("{}{}".format(mtype, mid)) measure = self.get_measure_set("{}{}".format(mtype, mid))
graph_name = "{}{}".format(mtype, mid) graph_name = "{}{}".format(mtype, mid)
# Generate the plot name from the metadata mask
metadata_info = ["{}".format(measure.metadata[metadata_name]) for metadata_name in metadata_masks[mtype]]
metadata_infos.append(", ".join(metadata_info))
if props_type == 'histogram': if props_type == 'histogram':
measure.generate_histogram(i, colors[j]) subplots.append(measure.generate_histogram(i, colors[j], metadata_info))
else: else:
measure.generate_chrono_graph(i, colors[j]) subplots.append(measure.generate_chrono_graph(i, colors[j], metadata_info))
fig, ax = plt.gcf(), plt.gca() fig, ax = plt.gcf(), plt.gca()
...@@ -127,16 +134,61 @@ class MeasureSetHandler: ...@@ -127,16 +134,61 @@ class MeasureSetHandler:
ax.set_xlabel('Time (us)') ax.set_xlabel('Time (us)')
ax.set_ylabel(prop_name) ax.set_ylabel(prop_name)
ax.set_title('{}, {} graph'.format(mtype, prop_name)) ax.set_title('{}, {} graph'.format(mtype, prop_name))
plt.legend(subplots, metadata_infos)
#ax.legend(fancybox=True, framealpha=1, shadow=True, borderpad=1)
fig.set_size_inches(11.0, 5.5) fig.set_size_inches(11.0, 5.5)
# Save the graph # Save the graph
plt.savefig("{}/{}{}.png".format(MeasureSetHandler.graphs_dir, mtype, prop_name)) plt.savefig("{}/{}{}.png".format(MeasureSetHandler.graphs_dir, mtype, prop_name))
plt.clf() plt.clf()
def generate_metadata_text(self):
metadata_masks = {}
common_metadata_strs = {}
for mtype in self.measure_sets:
metadata_mask = []
measures = []
for mid in self.measure_sets[mtype]['ids']:
measures.append(self.get_measure_set("{}{}".format(mtype, mid)))
if len(measures) == 0:
continue
first_metadata = measures[0].metadata
# Generate the metadata mask, by grouping the identical metadata
for measure in measures[1:]:
for metadata_name in measure.metadata:
# If it is not already in the metadata mask
if metadata_name not in metadata_mask:
# If there are two different metadata, they are added to the mask
if measure.metadata[metadata_name] != first_metadata[metadata_name]:
metadata_mask.append(metadata_name)
metadata_masks[mtype] = metadata_mask
# Compute the identical metadata
common_metadata = []
for metadata_name in first_metadata:
if metadata_name not in metadata_mask:
if metadata_name in MeasureSet.abbreviations:
common_metadata.append("{}: {}".format(MeasureSet.abbreviations[metadata_name], first_metadata[metadata_name]))
else:
common_metadata.append("{}: {}".format(metadata_name, first_metadata[metadata_name]))
common_metadata_strs[mtype] = ", ".join(common_metadata)
return (metadata_masks, common_metadata_strs)
def generate_report(self, include_graphs=True): def generate_report(self, include_graphs=True):
metadata_masks, common_metadata_strs = self.generate_metadata_text()
if include_graphs: if include_graphs:
self.generate_graphs() self.generate_graphs(metadata_masks)
with open(self.measures_dir + "/" + "measure-report.md", 'w+') as report: with open(self.measures_dir + "/" + "measure-report.md", 'w+') as report:
...@@ -151,37 +203,17 @@ class MeasureSetHandler: ...@@ -151,37 +203,17 @@ class MeasureSetHandler:
need_header = True need_header = True
props_lens = [] props_lens = []
report.write("### {} tables\n\n".format(mtype)) report.write("### {} results\n\n".format(mtype))
# Generate the metadata mask, by grouping the identical metadatas
metadata_mask = []
measures = [] measures = []
for mid in self.measure_sets[mtype]['ids']: for mid in self.measure_sets[mtype]['ids']:
measures.append(self.get_measure_set("{}{}".format(mtype, mid))) measures.append(self.get_measure_set("{}{}".format(mtype, mid)))
if len(measures) == 0: if len(measures) == 0:
continue continue
first_metadata = measures[0].metadata first_metadata = measures[0].metadata
for measure in measures[1:]: # Write the identical metadata before the table
for metadata_name in measure.metadata: report.write("**Common test metadata:** {}\n\n".format(common_metadata_strs[mtype]))
# If it is not already in the metadata mask
if metadata_name not in metadata_mask:
# If there are two different metadatas, they are added to the mask
if measure.metadata[metadata_name] != first_metadata[metadata_name]:
metadata_mask.append(metadata_name)
# Write the identical metadatas before the table
report.write("**Common metadatas:** ")
common_metadatas = []
for metadata_name in first_metadata:
if metadata_name not in metadata_mask:
if metadata_name in MeasureSet.abbreviations:
common_metadatas.append("{}: {}".format(MeasureSet.abbreviations[metadata_name], first_metadata[metadata_name]))
else:
common_metadatas.append("{}: {}".format(metadata_name, first_metadata[metadata_name]))
report.write(", ".join(common_metadatas) + "\n\n")
for mid in self.measure_sets[mtype]['ids']: for mid in self.measure_sets[mtype]['ids']:
...@@ -189,11 +221,11 @@ class MeasureSetHandler: ...@@ -189,11 +221,11 @@ class MeasureSetHandler:
if need_header: if need_header:
table_str, props_lens = measure.generate_table(headers=True, metadata_mask=metadata_mask) table_str, props_lens = measure.generate_table(headers=True, metadata_mask=metadata_masks[mtype])
report.write(table_str) report.write(table_str)
need_header = False need_header = False
else: else:
report.write(measure.generate_table(headers=False, props_lens=props_lens, metadata_mask=metadata_mask)[0]) report.write(measure.generate_table(headers=False, props_lens=props_lens, metadata_mask=metadata_masks[mtype])[0])
report.write("\n") report.write("\n")
...@@ -217,6 +249,7 @@ class MeasureSet: ...@@ -217,6 +249,7 @@ class MeasureSet:
'boot_p': 'Boot Parameters', 'boot_p': 'Boot Parameters',
'delta': 'ETF qdisc delta', 'delta': 'ETF qdisc delta',
'load': 'Device and processor load', 'load': 'Device and processor load',
'duration': 'Test duration',
} }
def __init__(self): def __init__(self):
...@@ -377,7 +410,7 @@ class MeasureSet: ...@@ -377,7 +410,7 @@ class MeasureSet:
self.add_chronological(props_names, props) self.add_chronological(props_names, props)
def generate_histogram(self, i, color): def generate_histogram(self, i, color, name):
bins = [i for i in range(self.max[i] + 1)] bins = [i for i in range(self.max[i] + 1)]
vals = self.props[i][:self.max[i] + 1] vals = self.props[i][:self.max[i] + 1]
...@@ -386,12 +419,12 @@ class MeasureSet: ...@@ -386,12 +419,12 @@ class MeasureSet:
vals = list(map(lambda x: min_val if x != 0 and x < min_val else x, vals)) vals = list(map(lambda x: min_val if x != 0 and x < min_val else x, vals))
plt.bar(bins, vals, alpha=0.4) return plt.bar(bins, vals, alpha=0.4)
def generate_chrono_graph(self, i, color): def generate_chrono_graph(self, i, color, name):
prop = self.props[i] prop = self.props[i]
x = [i for i in range(len(prop))] x = [i for i in range(len(prop))]
plt.plot(x, prop, color=color) return plt.plot(x, prop, color=color)
def generate_table(self, headers=True, values=True, metadata_mask=[], props_lens=[]): def generate_table(self, headers=True, values=True, metadata_mask=[], props_lens=[]):
......
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
* boot_p: Boot Parameters * boot_p: Boot Parameters
* delta: ETF qdisc delta * delta: ETF qdisc delta
* load: Device and processor load * load: Device and processor load
* duration: Test duration
### cyclictest_wake-up_latency tables ### cyclictest_wake-up_latency results
**Common metadatas:** Linux kernel version: 4.19, Boot Parameters: isolcpus, Interval: 200us, ETF qdisc delta: 200us, Task priority: 99, Device and processor load: hackbench, duration: 21h22 **Common test metadata:** Linux kernel version: 4.19, Boot Parameters: isolcpus, Interval: 200us, ETF qdisc delta: 200us, Task priority: 99, Device and processor load: hackbench, Test duration: 21h22
Metadata | Min | Max | Avg | Var Metadata | Min | Max | Avg | Var
--------- | ------------------- | ------------------- | ------------------- | ------------------- --------- | ------------------- | ------------------- | ------------------- | -------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment