import datetime
# Data
dates = [datetime.datetime(2019, 2, 11, 5, 10, 56), datetime.datetime(2019, 2, 11, 7, 13, 28), datetime.datetime(2019, 2, 11, 9, 20, 34), datetime.datetime(2019, 2, 11, 13, 52, 54), datetime.datetime(2019, 2, 11, 21, 29, 29), datetime.datetime(2019, 2, 12, 7, 8, 18), datetime.datetime(2019, 2, 12, 12, 19, 57), datetime.datetime(2019, 2, 12, 13, 31, 56), datetime.datetime(2019, 2, 12, 16, 14, 5), datetime.datetime(2019, 2, 12, 17, 59, 25), datetime.datetime(2019, 2, 12, 19, 13, 43), datetime.datetime(2019, 2, 13, 10, 48, 21), datetime.datetime(2019, 2, 13, 12, 42, 42), datetime.datetime(2019, 2, 13, 14, 50, 15), datetime.datetime(2019, 2, 13, 16, 13, 16), datetime.datetime(2019, 2, 14, 13, 58, 39), datetime.datetime(2019, 2, 14, 15, 4, 27), datetime.datetime(2019, 2, 14, 16, 8, 42), datetime.datetime(2019, 2, 15, 8, 50, 21), datetime.datetime(2019, 2, 15, 11, 4, 10), datetime.datetime(2019, 2, 15, 12, 25, 21), datetime.datetime(2019, 2, 15, 13, 39, 52), datetime.datetime(2019, 2, 15, 14, 55, 6), datetime.datetime(2019, 2, 15, 16, 9, 21), datetime.datetime(2019, 2, 15, 23, 8, 50)]
# y values
show_times = [45.2, 45.19, 45.24, 45.99, 46.12, 45.46, 45.52, 45.44, 41.93, 41.69, 41.74, 42.0, 42.13, 42.33, 43.15, 42.85, 43.29, 42.48, 43.21, 40.42, 40.44, 40.46, 40.77, 40.84, 42.96]
show_with_cache_times = [26.33, 26.36, 26.35, 26.27, 26.24, 26.52, 26.43, 26.6, 23.07, 23.06, 23.1, 22.99, 23.4, 23.36, 23.38, 23.27, 23.25, 23.16, 23.25, 22.31, 22.26, 22.5, 22.49, 22.53, 22.64]
build_with_cache_times = [235.28, 236.42, 236.05, 235.98, 237.04, 233.35, 232.25, 232.96, 223.9, 224.01, 223.91, 223.71, 227.06, 223.99, 229.21, 230.39, 227.3, 228.76, 227.43, 226.01, 225.27, 227.03, 224.38, 227.4, 224.45]
show_once_built_times = [32.32, 32.46, 32.39, 32.78, 32.9, 32.49, 32.44, 32.55, 28.88, 29.66, 29.09, 29.03, 28.99, 29.2, 29.95, 29.11, 29.5, 28.96, 29.41, 28.59, 28.68, 28.45, 28.42, 28.32, 28.78]
show_memory = [402.0, 401.892, 401.904, 401.952, 401.968, 401.896, 401.828, 401.576, 401.748, 401.804, 401.628, 401.836, 408.168, 408.132, 395.012, 395.228, 391.708, 391.832, 391.624, 409.908, 409.92, 409.888, 409.912, 410.028, 409.964]
show_with_cache_memory = [426.404, 426.352, 426.264, 426.388, 426.416, 426.192, 426.128, 426.208, 425.904, 426.056, 426.204, 426.108, 432.524, 432.664, 419.896, 419.772, 416.456, 416.456, 416.368, 424.632, 424.504, 424.564, 424.616, 424.536, 424.552]
build_with_cache_memory = [427.164, 427.104, 426.944, 427.136, 427.536, 426.808, 427.004, 427.592, 426.984, 427.056, 427.08, 427.324, 433.876, 433.756, 420.016, 420.1, 416.752, 416.848, 416.9, 424.824, 424.8, 424.94, 424.964, 424.916, 424.584]
show_once_built_memory = [427.908, 427.968, 427.792, 427.812, 427.924, 427.948, 427.82, 428.0, 427.976, 427.968, 428.056, 428.02, 434.632, 434.644, 421.556, 421.408, 417.92, 418.02, 418.128, 425.24, 425.172, 425.052, 425.096, 425.112, 424.936]
# Additional data
commits = ['5e1be71f', 'c07cc967', 'bb6a692d', 'a66f8379', '0816b8b1', '86a9048a', 'dbce3434', '95d9b9ae', '022a59f0', 'e51116d5', '6de65306', '8c6baf23', 'ae0ee361', '54ec032a', '9db7f489', '868c057e', '174f5394', '56c07baa', '51dae747', '14176e51', '8b34e356', '0921ccf4', '91eb29a6', '677fc6c5', '232906b1']
branches = ['!1141: juerg/import', '!1138: juerg/symlinks', '!1129: snakeviz', '!891: aevri/include-error', '!1145: jjardon/allow_fail_WSL', '!1142: juerg/buffer-size', '!1121: chandan/deps', '!1137: jjardon/fedora_29', '!1131: danielsilverstone-ct/further-optimisations', '!1134: jonathan/junction-no-tmpdir', '!1144: valentindavid/pull-chmod-bug', '!1101: jennis/refactor_artifact_log', '!1139: juerg/list-all-directories', '!1135: tpollard/896', '!1147: bschubert/cleanup-local-state', '!1151: danielsilverstone-ct/json-cache-key', '!1150: bschubert/dont-keep-metasource', '!1140: juerg/symlinks2', '!1148: chandan/dot-graph', '!1152: danielsilverstone-ct/variables-rework', '!1149: aevri/mtime1', '!1154: bschubert/set-as-set', '!1130: are_you_sure2', '!1153: chandan/bst-here-tags', '!1143: jjardon/distros']
import matplotlib.pyplot as plt
import mplcursors
# Note mplcursors is required to show commit info when we hover over a data point
# The package can be installed with pip3: pip3 install mplcursors
# Time taken to show Debian's base files
%matplotlib notebook
fig1, ax1 = plt.subplots()
# Plot date vs time (cache and no cache)
ax1.plot(dates, show_times,'x:', label='No YAML cache')
ax1.plot(dates, show_with_cache_times, 'x:r', label='With YAML cache')
ax1.plot(dates, show_once_built_times, 'x:g', label='With YAML cache and built elements')
# This is hacky, but allows us to see commits when we hover over
scatter1 = ax1.scatter(dates + dates + dates, show_times + show_with_cache_times + show_once_built_times, marker='x')
# Labelling
ax1.set_title("Time taken to 'bst show' Debian's base-files\n for last week's merge commits")
ax1.set_xlabel('Date')
ax1.set_ylabel('Time (s)')
ax1.legend(loc='lower left')
ax1.grid()
# Limit the y axis
ax1.set_ylim([0, max([max(show_times), max(show_with_cache_times), max(show_once_built_times)])+5])
fig1.autofmt_xdate() # Make the xaxis pretty
# Add commit info to data points when mouse is hovered over
labels = branches + branches + branches
cursor = mplcursors.cursor(scatter1, hover=False)
cursor.connect(
"add", lambda sel: sel.annotation.set_text(labels[sel.target.index]))
# Maximum memory when showing Debian's base-files
%matplotlib notebook
fig2, ax2 = plt.subplots()
# Plot date vs time (cache and no cache)
ax2.plot(dates, show_memory,'x:', label='No YAML cache')
ax2.plot(dates, show_with_cache_memory, 'x:r', label='With YAML cache')
ax2.plot(dates, show_once_built_memory, 'x:g', label='With YAML cache and built elements')
# HACKY scatter
scatter2 = ax2.scatter(dates + dates + dates, show_memory + show_with_cache_memory + show_once_built_memory, marker='x')
# Labelling
ax2.set_title("Maxmimum memory when invoking 'bst show' on Debian's base-files\n for last week's merge commits")
ax2.set_xlabel('Date')
ax2.set_ylabel('Max memory (Mbytes)')
ax2.legend(loc='lower left')
ax2.grid()
# Limit the y axis
ax2.set_ylim([0, max([max(show_memory), max(show_with_cache_memory), max(show_once_built_memory)]) + 50])
fig2.autofmt_xdate() # Make the xaxis pretty
# Add commit info to data points when mouse is hovered over
labels = branches + branches + branches
cursor = mplcursors.cursor(scatter2, hover=False)
cursor.connect(
"add", lambda sel: sel.annotation.set_text(labels[sel.target.index]))
# Time taken to build Debian's base-files
%matplotlib notebook
fig3, ax3 = plt.subplots()
# Plot date vs time (cache and no cache)
ax3.plot(dates, build_with_cache_times,'x:')
# Hacky scatter for hovering over data points
scatter3 = ax3.scatter(dates, build_with_cache_times, marker='x')
# Labelling
ax3.set_title("Time taken to 'build' Debian's base-files\n for last week's merge commits")
ax3.set_xlabel('Date')
ax3.set_ylabel('Time (s)')
ax3.grid()
# Limit the y axis
ax3.set_ylim([0, max(build_with_cache_times) + 50])
fig3.autofmt_xdate() # Make the xaxis pretty
# Add commit info to data points when mouse is hovered over
cursor = mplcursors.cursor(scatter3, hover=False)
cursor.connect(
"add", lambda sel: sel.annotation.set_text(branches[sel.target.index]))
# Maximum memory when building Debian's base-files
%matplotlib notebook
fig4, ax4 = plt.subplots()
# Plot date vs time (cache and no cache)
# Note this is a line graph with a scatter plot on top, so that we can attach info to data points
line = ax4.plot(dates, build_with_cache_memory,':')
scatter4 = ax4.scatter(dates, build_with_cache_memory, marker='x')
# Title and label axis and add grid
ax4.set_title("Max memory usage when 'building' Debian's base-files\n for last week's merge commits")
ax4.set_xlabel('Date')
ax4.set_ylabel('Memory (Mbytes)')
ax4.grid()
ax4.set_ylim([0, max(build_with_cache_memory) + 50]) # Limit the y axis
fig4.autofmt_xdate() # Make the xaxis pretty
# Add commit info to data points when mouse is hovered over
cursor = mplcursors.cursor(scatter4, hover=False)
cursor.connect(
"add", lambda sel: sel.annotation.set_text(branches[sel.target.index]))