Last active
February 17, 2020 03:16
-
-
Save Olshansk/39d51402401ce69262acafd0b824279e to your computer and use it in GitHub Desktop.
Visualize the results of all the aggregated stats profiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FormatStrFormatter | |
WIDTH = 0.4 | |
ind = np.arange(len(time_sliced_counters)) | |
x_axis = tuple(time for (time, c) in time_sliced_counters) | |
y_axis = [[] for _ in range(len(headers))] | |
for idx, header in enumerate(headers): | |
for (time, counter) in time_sliced_counters: | |
y_axis[idx].append(counter[header]) | |
fig = matplotlib.pyplot.gcf() | |
fig.set_size_inches(18.5, 10.5) | |
boxes = [] | |
titles = [] | |
bottom = np.zeros(len(y_axis[0])) | |
for idx, header in enumerate(headers): | |
p = plt.bar(ind, tuple(y_axis[idx]), WIDTH, bottom=bottom) | |
bottom += np.array(y_axis[idx]) | |
boxes.append(p[0]) | |
titles.append(header) | |
plt.ylabel("Total time (s)", fontsize=12) | |
plt.yticks(np.arange(0, round(max(bottom) + 5), 1), fontsize=12) | |
plt.gca().yaxis.set_major_formatter(FormatStrFormatter('%.2f')) | |
plt.xlabel('time (epoch)', fontsize=12) | |
plt.xticks(ind, x_axis, fontsize=12, rotation=45) | |
plt.title(f"Application profile at {TIME_SLICE}s time slices") | |
plt.legend(tuple(boxes), tuple(titles), fontsize=12, ncol=3, fancybox=True, loc='upper center', bbox_to_anchor=(0.5, -0.2), shadow=True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment