Performance of nextInt(int) in BitsStreamGenerator can be improved
------------------------------------------------------------------

                 Key: MATH-642
                 URL: https://issues.apache.org/jira/browse/MATH-642
             Project: Commons Math
          Issue Type: Improvement
    Affects Versions: 2.2, 2.1, 2.0
            Reporter: Phil Steitz
            Priority: Minor
             Fix For: 3.0


The code used to implement this method in Apache Harmony's Random class 
performs better with the Mersenne and Well generators as bit sources as well as 
the JDK generator.  Here are some benchmark testing results ("orginal" is the 
current code):

nextInt(10) comparison - JDK generator (runs per timed block: 100000, timed 
blocks: 1000)
original value = 10: 5.417883e-05 (1.010215e-05) ms
harmony value = 10: 3.808923e-05 (1.090630e-05) ms
nextInt(100) comparison - JDK generator (runs per timed block: 100000, timed 
blocks: 1000)
original value = 100: 4.602311e-05 (5.075280e-06) ms
harmony value = 100: 3.771343e-05 (5.836102e-06) ms
nextInt(10000) comparison - JDK generator (runs per timed block: 100000, timed 
blocks: 1000)
original value = 10000: 5.317242e-05 (5.527069e-06) ms
harmony value = 10000: 3.676283e-05 (5.062836e-06) ms
nextInt(32) comparison - JDK generator (runs per timed block: 100000, timed 
blocks: 1000)
original value = 32: 6.225222e-05 (1.143497e-05) ms
harmony value = 32: 3.875278e-05 (6.099984e-06) ms

nextInt(10) comparison - Well1024a (runs per timed block: 100000, timed blocks: 
1000)
original value = 10: 4.365601e-05 (1.013942e-05) ms
harmony value = 10: 4.141704e-05 (1.778676e-05) ms
nextInt(100) comparison - Well1024a (runs per timed block: 100000, timed 
blocks: 1000)
original value = 100: 3.579893e-05 (4.670346e-06) ms
harmony value = 100: 3.474323e-05 (5.273507e-06) ms
nextInt(10000) comparison - Well1024a (runs per timed block: 100000, timed 
blocks: 1000)
original value = 10000: 4.431216e-05 (5.654163e-06) ms
harmony value = 10000: 3.440765e-05 (4.282874e-06) ms
nextInt(32) comparison - Well1024a (runs per timed block: 100000, timed blocks: 
1000)
original value = 32: 5.080220e-05 (7.276901e-06) ms
harmony value = 32: 2.958944e-05 (1.091995e-05) ms

nextInt(10) comparison - MersenneTwister (runs per timed block: 100000, timed 
blocks: 1000)
original value = 10: 4.365044e-05 (1.284578e-05) ms
harmony value = 10: 3.199023e-05 (7.170367e-06) ms
nextInt(100) comparison - MersenneTwister (runs per timed block: 100000, timed 
blocks: 1000)
original value = 100: 3.488505e-05 (4.822188e-06) ms
harmony value = 100: 3.145389e-05 (5.290716e-06) ms
nextInt(10000) comparison - MersenneTwister (runs per timed block: 100000, 
timed blocks: 1000)
original value = 10000: 4.468017e-05 (1.086927e-05) ms
harmony value = 10000: 3.274545e-05 (2.059499e-05) ms
nextInt(32) comparison - MersenneTwister (runs per timed block: 100000, timed 
blocks: 1000)
original value = 32: 5.129467e-05 (6.652250e-06) ms
harmony value = 32: 2.569880e-05 (8.063487e-06) ms


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to