vendredi 9 mars 2018

Conflicting performance results of random number generators

Coming from my question on Code-Review, some analysis of the performance of random number generating libraries was done, specifically python and numpy's random facilities. One would assume that there would be some differences of performance on different machines, but the overall conclusion would be the same, x is faster than y. However, that is not the case.

In Oscar Smith's answer, he performed a test, and got the following results:

timeit.timeit('rand(0,1000)', setup='from numpy.random import uniform as rand')
0.7485988769913092
timeit.timeit('rand(0,1000)', setup='from random import uniform as rand')
0.2676771300029941


I performed the same test, and got opposite results:

timeit.timeit("rand(0, 1000)", setup="from numpy.random import uniform as rand")
0.1250929832458496
timeit.timeit("rand(0, 1000)", setup="from random import uniform as rand")
0.47645998001098633

I would expect that these values would be different, but proportionally the same, ie he would get 0.5, 0.1, and I would get 0.25, 0.05. However, we got direct opposite results. What's going on here? And if possible, which library is officially considered faster?




Aucun commentaire:

Enregistrer un commentaire