My goal is to evaluate execution times between two different functions that output the same result. I am looking at np.linalg.det() and a function I made called mydet().
For each loop, I would like to generate a n x n matrix with n being in the range of (2,9). The 2 because any less wouldn't be a matrix, and 9 because any larger and the execution time would be significant.
I want the n value to correspond to the loop value i, so would n = i + 2? i starts at 0, and I need n to start at 2.
I want to measure the time it takes for each loop, and append it to an empty list called my_det_time and np_det_time, respectively.
Right now, my code only calculates the sum of the execution time. Whereas I would like to take each loop's time and append to the lists I specified.
What do I need to change in order to evaluate each loops' time and append that loops' time to a list, so I can see the progression of times as the matrix gets larger, and then plot the data to compare?
Thanks
import time
start_time = time.time()
from random import randint
my_det_time = []
np_det_time = []
for i in range(8):
n = i+2
s = 10
A = [[round(random.random()*s) for i in range(n)] for j in range(n)]
np.linalg.det(A)
print("%s seconds" % (time.time() - start_time))