3 ms·
You might be misremembering the numpy.random api, since you appear to only be generating one or two random numbers in your tests. I get results about 100x slow
by nimih 7y ago
You might be misremembering the numpy.random api, since you appear to only be generating one or two random numbers in your tests.
I get results about 100x slower those of the article's CPU benchmark when using numpy on a 2019 MBP:
python -m timeit -s 'import numpy as np; x = np.zeros(1000000)' -u msec 'np.random.normal(x)'
10 loops, best of 5: 30.9 msec per loop
edit: I'm no python wizard myself, so I'm perfectly willing to believe that there's a better way to generate a random array in numpy than what I'm doing.