I have used a similar method used in numpy lecture, but using "time.perf_counter()" instead of "datetime.now()", why? because I did not find any difference and I usually use that.

The code is shown as follows:

Code: Select all

```
import numpy as np
import time
A = np.array([[1,2,3], [4,5,6], [7,8,9]])
#A = np.ones((3,3)) * 3
B = np.ones((3,3)) * 2
X = np.zeros((3,3)) #Matrix dot solution
sum1 = 0
sum2 = 0
med1 = 0
med2 = 0
#Manual method
for loop in range(0,500):
t1 = time.perf_counter()
for k in range(0,2+1):
for i in range(0,2+1):
e = 0
for j in range(0,2+1):
e = e + (A[k,j] * B[j,i])
X[k,i] = e
t2 = time.perf_counter()
sum1 = sum1 + (t2 - t1)
med1 = sum1/50
for loop2 in range(0,500):
t1 = time.perf_counter()
A.dot(B)
t2 = time.perf_counter()
```