[ https://issues.apache.org/jira/browse/MATH-1300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15065489#comment-15065489 ]
Gilles commented on MATH-1300: ------------------------------ Two runs from me: ;) {noformat} nextBytes (calls per timed block: 200000, timed blocks: 100, time unit: ms) name time/call std error total time ratio difference Rostislav 2.27207249e-04 5.12523201e-05 4.5441e+03 1.0000e+00 0.00000000e+00 Gilles 2.41729594e-04 3.13763057e-05 4.8346e+03 1.0639e+00 2.90446893e+02 CommonsMath 2.25267632e-04 3.46659491e-05 4.5054e+03 9.9146e-01 -3.87923460e+01 {noformat} {noformat} nextBytes (calls per timed block: 200000, timed blocks: 100, time unit: ms) name time/call std error total time ratio difference Rostislav 2.32682559e-04 3.84982763e-05 4.6537e+03 1.0000e+00 0.00000000e+00 Gilles 2.49178627e-04 3.92662253e-05 4.9836e+03 1.0709e+00 3.29921360e+02 CommonsMath 2.26983378e-04 2.72215448e-05 4.5397e+03 9.7551e-01 -1.13983632e+02 {noformat} I'm still ~7% slower than you, but that's far from the ~50% which your benchmark indicates. In your benchmark, your code is faster that the current CM code; but in mine, it's the other way around... > BitsStreamGenerator#nextBytes(byte[]) is wrong > ---------------------------------------------- > > Key: MATH-1300 > URL: https://issues.apache.org/jira/browse/MATH-1300 > Project: Commons Math > Issue Type: Bug > Affects Versions: 3.5 > Reporter: Rostislav Krasny > Attachments: MersenneTwister2.java, TestMersenneTwister.java > > > Sequential calls to the BitsStreamGenerator#nextBytes(byte[]) must generate > the same sequence of bytes, no matter by chunks of which size it was divided. > This is also how java.util.Random#nextBytes(byte[]) works. > When nextBytes(byte[]) is called with a bytes array of length multiple of 4 > it makes one unneeded call to next(int) method. This is wrong and produces an > inconsistent behavior of classes like MersenneTwister. > I made a new implementation of the BitsStreamGenerator#nextBytes(byte[]) see > attached code. -- This message was sent by Atlassian JIRA (v6.3.4#6332)