import numpy as np
import time
import math
bt = time.time()
n = 1000
for i in range(1):
a = np.random.uniform(low=0., high=1., size=(n, n)).astype(np.float32)
b = np.random.uniform(low=0., high=1., size=(n, n)).astype(np.float32)
a = a.dot(b)
print ('(%d * %d),Total Time:%.3f'%(n,n,time.time()-bt))
start = time.clock()
x = [i * 0.001 for i in xrange(10000000)]
for i, t in enumerate(x):
x[i] = math.sin(t)
print ("math.sin:%.3f"%(time.clock() - start))
start = time.clock()
y = [i * 0.001 for i in xrange(10000000)]
y = np.array(y)
print ("numpy.sin1:%.3f"%(time.clock() - start))
start = time.clock()
np.sin(y,y)
print ("numpy.sin2:%.3f"%(time.clock() - start))
'''
* ipad Pro 9.7
(1000 * 1000),Total Time:8.840
math.sin: 3.04883
numpy.sin: 2.668903 (2.517,0.177)
=====Android Termux=====
(1000,1000) 0.627
math.sin: 33.899
numpy.sin: 14.953
=====MacBook Air 13 @2010====
(1000,1000) 0.234
math.sin: 8.95
numpy.sin: 4.71 (3.88,0.48)
====Microsoft Surface 3 @2015====
(1000,1000) 0.203
math.sin: 12.739
numpy.sin: (5.419,0.380)
Why iOS numpy (1000,1000) very slow ???