Skip to content

Instantly share code, notes, and snippets.

@painor
Created December 10, 2020 13:51
Show Gist options
  • Save painor/f8a9574fc17c3a3a6212558478d3d00c to your computer and use it in GitHub Desktop.
Save painor/f8a9574fc17c3a3a6212558478d3d00c to your computer and use it in GitHub Desktop.
A small helper script to plot timeit results
import matplotlib.pyplot as plt
from timeit import timeit
time_taken = []
number_elements = [*range(15)]
for x in range(1, 16):
string = 'a' * x
best = timeit("for _ in TrashGuy(inp): pass", setup=f"from trashguy import TrashGuy;inp='{string}'", number=1000)
time_taken.append(best)
plt.plot(time_taken, number_elements, color='g', marker='o')
plt.xlabel('Time Taken (seconds)')
plt.ylabel('Number of elements')
plt.title('Trash guy')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment