Last active
April 23, 2017 13:16
Revisions
-
n-eq revised this gist
Apr 23, 2017 . 1 changed file with 2 additions and 6 deletions.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 @@ -1,4 +1,3 @@ import numpy as np import matplotlib.pyplot as plt import timeit @@ -13,12 +12,9 @@ start_time=timeit.default_timer() for i in range(b): for j in range(b): for ii in range(i, min(i + b, n) + 1, b): for jj in range(j, min(j + b, n) + 1, b): tab[ii][jj] = np.random.rand() ii += b elapsed = timeit.default_timer() - start_time print("block: " + str(b) + ", elapsed: " + str(elapsed)) -
n-eq created this gist
Apr 23, 2017 .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,30 @@ import numpy as np import matplotlib.pyplot as plt import timeit plt.ion() n=10000 block=[i+1 for i in range(1000)] time=[] tab=[[0 for i in range(n)] for j in range(n)] for b in block: start_time=timeit.default_timer() for i in range(b): for j in range(b): ii=i jj=j while (ii < min(i + b, n)): while (jj < min(j + b, n)): tab[ii][jj] = np.random.rand() jj += b ii += b elapsed = timeit.default_timer() - start_time print("block: " + str(b) + ", elapsed: " + str(elapsed)) time.append(elapsed) plt.scatter(b, elapsed) plt.pause(0.05) while True: plt.pause(0.05)