[ 
https://issues.apache.org/jira/browse/RNG-57?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16689734#comment-16689734
 ] 

ASF GitHub Bot commented on RNG-57:
-----------------------------------

GitHub user aherbert opened a pull request:

    https://github.com/apache/commons-rng/pull/12

    RNG-57: Cache values for provision of nextBoolean and nextInt

    This PR contains the suggested changes to implement a cache to speed up the 
`nextInt` and `nextBoolean` methods in the core provider implementations.
    
    These changes improve performance but the effect on the `nextInt` method of 
`LongProvider` is unknown. A repeat of the DieHarder and TestU01 test suites is 
currently in progress.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aherbert/commons-rng improvement-RNG-57

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-rng/pull/12.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12
    
----
commit 91a5eec2d8a3318cf8fc8e6d222ac3edf3a0d969
Author: aherbert <a.herbert@...>
Date:   2018-11-16T13:10:51Z

    RNG-57: Cache values for provision of nextBoolean and nextInt

----


> CachedUniformRandomProvider for nextBoolean() and nextInt()
> -----------------------------------------------------------
>
>                 Key: RNG-57
>                 URL: https://issues.apache.org/jira/browse/RNG-57
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: core
>            Reporter: Alex D Herbert
>            Priority: Minor
>              Labels: performance
>             Fix For: 1.2
>
>
> Implement a wrapper around a {{UniformRandomProvider}} that can cache the 
> underlying source of random bytes for use in the methods {{nextBoolean()}} 
> and {{nextInt()}} (in the case of {{LongProvider}}). E.g.
> {code:java}
> LongProvider provider = RandomSource.create(RandomSource.SPLIT_MIX_64);
> CachedLongProvider rng = new CachedLongProvider(provider);
> // Uses cached nextLong() 64 times
> rng.nextBoolean();
> // Uses cached nextLong() twice
> rng.nextInt();
> IntProvider provider = RandomSource.create(RandomSource.KISS);
> CachedIntProvider rng2 = new CachedIntProvider(provider);
> // Uses cached nextInt() 32 times
> rng2.nextBoolean();
> // This could be wrapped by a factory method:
> UniformRandomProvider rng = CachedUniformRandomProviderFactory.wrap(
>         // Any supported source: IntProvider or LongProvider
>         RandomSource.create(RandomSource...));
> {code}
> The implementation should be speed tested to determine the benefit for 
> {{nextBoolean()}} and if {{nextInt()}} can be improved for {{LongProviders}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to