Created
December 10, 2020 13:51
-
-
Save painor/f8a9574fc17c3a3a6212558478d3d00c to your computer and use it in GitHub Desktop.
A small helper script to plot timeit results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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