Skip to content

Instantly share code, notes, and snippets.

@fabidick22
Last active November 23, 2023 05:00
Show Gist options
  • Save fabidick22/03cdf8ae2a9097474650b3c8758ad05c to your computer and use it in GitHub Desktop.
Save fabidick22/03cdf8ae2a9097474650b3c8758ad05c to your computer and use it in GitHub Desktop.
import plotly.graph_objects as go
import sqlite3
conn = sqlite3.connect('ecs_data_v1.sqlite')
conn_v2 = sqlite3.connect('ecs_data_v2.sqlite')
cursor = conn.cursor()
cursor_v2 = conn_v2.cursor()
avg_query = '''
SELECT taskFamily, AVG(timeDifferenceInSeconds)
FROM tasks
GROUP BY taskFamily
'''
cursor.execute(avg_query)
cursor_v2.execute(avg_query)
results = cursor.fetchall()
results_v2 = cursor_v2.fetchall()
conn.close()
conn_v2.close()
combined_results = {}
for result in results:
task_family, avg_time = result
combined_results[task_family] = {'v1': avg_time}
for result_v2 in results_v2:
task_family, avg_time_v2 = result_v2
if task_family in combined_results:
combined_results[task_family]['v2'] = avg_time_v2
else:
combined_results[task_family] = {'v2': avg_time_v2}
print("Task definition | AVG (Without SOCI) | AVG (SOCI)")
for task_family, times in combined_results.items():
print(f"{task_family} | {times.get('v1', 0)} | {times.get('v2', 0)}")
task_families = [str(name).replace("family:sh-runner-", "") for name in list(combined_results.keys())]
avg_times_v1 = [times.get('v1', 0) for times in combined_results.values()]
avg_times_v2 = [times.get('v2', 0) for times in combined_results.values()]
fig = go.Figure(data=[
go.Bar(name='Without SOCI', x=task_families, y=avg_times_v1),
go.Bar(name='SOCI', x=task_families, y=avg_times_v2)
])
fig.update_layout(barmode='group', yaxis_title="Seconds", xaxis_title="Task Definitions", xaxis_tickangle=-45)
fig.update_traces(texttemplate='%{y:.2f} s', textposition='outside')
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment