From 946d5f274a5b5a25cd98128e517d8ba2e7276dd7 Mon Sep 17 00:00:00 2001 From: "David B. Kinder" Date: Fri, 19 Aug 2022 15:11:25 -0700 Subject: [PATCH] Fix sample app histogram display Improve graph labels and align histogram bars on x-axis labels Add n= value to show it's not a static image. Tracked-On: #8025 Signed-off-by: David B. Kinder --- misc/sample_application/uservm/histapp.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/misc/sample_application/uservm/histapp.py b/misc/sample_application/uservm/histapp.py index b7cdad6bb..61f853d0e 100644 --- a/misc/sample_application/uservm/histapp.py +++ b/misc/sample_application/uservm/histapp.py @@ -40,17 +40,18 @@ def create_hist(): web_sem.release() #Transform the data into an array that matplotlib can understand - dataset = transform_data(data) + count, dataset = transform_data(data) #Clear the figure and recreate from the new data plt.clf() #Setup the figure and save it - figure = plt.hist(dataset) + bins=np.arange(min(dataset),max(dataset)+2)-0.5 + figure = plt.hist(dataset,bins,rwidth=0.5) - plt.title("Latency percentages") - plt.xlabel("Latency Value (us)") - plt.ylabel("Frequency") + plt.title("ACRN Sample Application cyclictest display (unoptimized)") + plt.xlabel("Latency Value (microseconds)") + plt.ylabel("Count Percentage " + f"{count:,}") plt.savefig("hist.png") return figure @@ -77,7 +78,7 @@ def transform_data(data_string): for i in range(0, int(len(data_percentages) / 2)): transformed_data_values += ([int(data_percentages[i*2])] * int(data_percentages[i*2 + 1])) - return transformed_data_values + return int(total_count), transformed_data_values if __name__ == '__main__':