Skip to content

Commit e148c57

Browse files
committed
Test scaling over an inner dimension
1 parent 2450078 commit e148c57

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

array_arithmetic.py

+24
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,27 @@ def size_of(array: np.ndarray) -> float:
177177
elapsed_time += end - start
178178
average = elapsed_time / N
179179
print("{:45}{:<15.6f}{:<15.6f}".format("0", elapsed_time, average))
180+
181+
182+
# Scaling when iterating over the middle index
183+
184+
BASE_DIM = 10
185+
N = 10
186+
for i in range(10):
187+
DIM = 10 ** i
188+
print(DIM)
189+
shape = ( 25, 72, DIM, 3, 3 )
190+
array1 = np.ones(shape)
191+
192+
elapsed_time = 0.0
193+
for _ in range(N):
194+
start = time.time()
195+
for i in range(DIM):
196+
a = array1[:,:,i,:,:] + 1
197+
198+
end = time.time()
199+
elapsed_time += end - start
200+
average = elapsed_time / N
201+
202+
array_size = int(np.prod(shape) * 8 / (1000 * 1000))
203+
print("{:8d} MB {:<15.6f}{:<15.6f}".format(array_size, elapsed_time, average))

0 commit comments

Comments
 (0)