Skip to content

Instantly share code, notes, and snippets.

@Hiroki-Kawakami
Created November 22, 2020 09:43
Show Gist options
  • Save Hiroki-Kawakami/a7740e043afac9497f0411c2593d8219 to your computer and use it in GitHub Desktop.
Save Hiroki-Kawakami/a7740e043afac9497f0411c2593d8219 to your computer and use it in GitHub Desktop.
Benchmark numpy with matrix multiplication
import numpy as np
from time import time
np.__config__.show()
np.random.seed(0)
size = 4096
A, B = np.random.rand(size, size), np.random.rand(size, size)
N = 20
t = time()
for i in range(N):
np.dot(A, B)
delta = time() - t
print('Dotted two %dx%d matrices in %0.2f s.' % (size, size, delta / N))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment