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

Gilles commented on RNG-57:
---------------------------

bq. This is an internal class. It implements the private interface 
{{CachedUniformRandomProvider}}.

Internal is good but I think that my remark still hold: an _interface_ is for 
specifying _what_ not _how_. :)
Anyway, this discussion is moot since IIUC the rest of your comment, the 
performance is always better, and thus the existing classes will just be 
modified to implement the cache.

bq. alterations to support {{RestorableUniformRandomProvider}}

Good catch.
This should be a separate issue/commit.

bq. alter the inheritance hierarchy

?
I get that part of the (complete) state should be handled in the base class and 
part in the concrete subclass.

bq. updating the benchmark tests shown in the User Guide

The benchmarking code is in class {{GenerationPerformance}} in module 
{{commons-rng-examples/examples-jmh}}.


> CachedUniformRandomProvider for nextBoolean() and nextInt()
> -----------------------------------------------------------
>
>                 Key: RNG-57
>                 URL: https://issues.apache.org/jira/browse/RNG-57
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: sampling
>    Affects Versions: 1.2
>            Reporter: Alex D Herbert
>            Priority: Minor
>              Labels: performance
>
> 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