Last active
April 27, 2017 10:56
-
-
Save semihyagcioglu/d1cabf7e284841460beb27bb4efd2428 to your computer and use it in GitHub Desktop.
This file contains 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 characters
# !/usr/bin/env python | |
import sys | |
import numpy as np | |
import numpy.random as npr | |
from numpy.distutils.system_info import get_info | |
import time | |
if __name__ == '__main__': | |
# Run diagnostics | |
print("NumPy Version: %s" % np.__version__) | |
print("Max int: %i\n" % sys.maxsize) | |
info = get_info('blas_opt') | |
print('BLAS info:') | |
for kk, vv in info.items(): | |
print(' * ' + kk + ' ' + str(vv)) | |
print("\n") | |
# Run Test 1 | |
N = 1 | |
n = 1000 | |
A = npr.randn(n, n) | |
B = npr.randn(n, n) | |
t = time.time() | |
for i in range(N): | |
C = np.dot(A, B) | |
td = time.time() - t | |
print("Dot product of two (%d,%d) matrices took %0.1f ms" % (n, n, 1e3 * td / N)) | |
# Run Test 2 | |
N = 100 | |
n = 2000 | |
A = npr.randn(n) | |
B = npr.randn(n) | |
t = time.time() | |
for i in range(N): | |
C = np.dot(A, B) | |
td = time.time() - t | |
print("Dot product of two (%d) d vectors took %0.2f us" % (n, 1e6 * td / N)) | |
# Run Test 3 | |
m, n = (1000, 2000) | |
A = npr.randn(m, n) | |
t = time.time() | |
[U, s, V] = np.linalg.svd(A, full_matrices=False) | |
td = time.time() - t | |
print("SVD of (%d,%d) matrix took %0.3f s" % (m, n, td)) | |
# Run Test 4 | |
n = 1000 | |
A = npr.randn(n, n) | |
t = time.time() | |
w, v = np.linalg.eig(A) | |
td = time.time() - t | |
print("Eigen decomposion of (%d,%d) matrix took %0.3f s" % (n, n, td)) | |
print("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment