def plot_progress_subplot(fig, row, col, df, metric, showlegend):
'''Plot evolution of execution time using Plotly.'''
df_pytorch, df_trv, df_trq = split_dataframe(df)
colors = ['rgba(31, 119, 180, 0.8)', 'rgba(255, 127, 14, 0.8)', 'rgba(44, 160, 44, 0.8)']
fig.add_trace(go.Scatter(x=df_pytorch["Datetime"], y=df_pytorch[metric], mode='lines+markers', name='PyTorch',
line=dict(color=colors[0]), showlegend=showlegend), row=row, col=col)
fig.add_trace(go.Scatter(x=df_trv["Datetime"], y=df_trv[metric], mode='lines+markers', name='tinyRuntime (no quant)',
line=dict(color=colors[1]), showlegend=showlegend), row=row, col=col)
fig.add_trace(go.Scatter(x=df_trq["Datetime"], y=df_trq[metric], mode='lines+markers', name='tinyRuntime (quant)',
line=dict(color=colors[2]), showlegend=showlegend), row=row, col=col)
def plot_progress(metric, ylabel, title, save_image=False):
fig = make_subplots(rows=2, cols=1, subplot_titles=('AMD64', 'ARM64'), shared_xaxes=True, vertical_spacing=0.15)
plot_progress_subplot(fig, 1, 1, df_x86, metric, showlegend=True)
plot_progress_subplot(fig, 2, 1, df_arm, metric, showlegend=False)
fig.update_xaxes(title_text="Datetime", row=2, col=1)
fig.update_xaxes(showticklabels=False, row=1, col=1)
fig.update_yaxes(title_text=ylabel, row=1, col=1)
fig.update_yaxes(title_text=ylabel, row=2, col=1)
fig.update_layout(height=800, showlegend=True,
legend=dict(orientation="h", yanchor="bottom", y=-0.2, xanchor="center", x=0.5),
legend_itemclick=False, legend_itemdoubleclick=False, font=dict(size=14), margin=dict(t=100, b=100, l=80, r=50),
template="plotly_dark", title=f"{title} History")
fig.show(config={'displayModeBar': False})
if save_image:
fig.write_image("images/perf_progress.png")
plot_progress("Time", "Time (s)", "Execution Time", save_image=True)