If you want to compare the performance between different Python snippets and plot the results, use perfplot.
Link to perfplot.
My previous tips on code review.