Last active
November 19, 2024 06:24
-
-
Save michaeldorner/c0fba1bc108fa230afd40d1d63d5df97 to your computer and use it in GitHub Desktop.
Revisions
-
michaeldorner revised this gist
Nov 19, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ sizes = [2**exp for exp in range(12)] # or np.arange(12) ;-) for size in sizes: numpy_results[size] = min(timeit.repeat(f'np.arange({size})', setup='import numpy as np', **config)) python_results[size] = min(timeit.repeat(f'range({size})', **config)) df = pd.concat((pd.Series(numpy_results, name='np.arange'), pd.Series(python_results, name='range')), axis=1) -
michaeldorner revised this gist
Feb 22, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ numpy_results[size] = min(timeit.repeat(f'np.arange({size})', setup='import numpy as np', **config)) python_results[size] = min(timeit.repeat(f'list(range({size}))', **config)) df = pd.concat((pd.Series(numpy_results, name='np.arange'), pd.Series(python_results, name='range')), axis=1) # plotting -
michaeldorner created this gist
Feb 22, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ import timeit import pandas as pd import matplotlib.pyplot as plt # measuring numpy_results = {} python_results = {} config = {'number': 100, 'repeat': 100} sizes = [2**exp for exp in range(12)] # or np.arange(12) ;-) for size in sizes: numpy_results[size] = min(timeit.repeat(f'np.arange({size})', setup='import numpy as np', **config)) python_results[size] = min(timeit.repeat(f'list(range({size}))', **config)) df = pd.concat((pd.Series(numpy_results, name='numpy'), pd.Series(python_results, name='Python')), axis=1) # plotting fig, ax = plt.subplots() df.plot(ax=ax) ax.set_xscale('log', base=2) ax.set_xticks(sizes) ax.set_xticklabels(sizes) ax.set_xlabel('Size') ax.set_ylabel('Best runtime for 10 runs out of 10 repetition')