commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex D Herbert (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (RNG-57) CachedUniformRandomProvider for nextBoolean() and nextInt()
Date Tue, 09 Oct 2018 12:12:00 GMT

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

Alex D Herbert commented on RNG-57:
-----------------------------------

bq. How would a single test detect which of the NumberFactory methods were buggy?

The {{NumberFactory}} is used in the base implementation of {{UniformRandomProvider}} by {{IntProvider}}
or {{LongProvider}}. I suggested that is tested once for all methods using e.g. SecureRandom
as the source. No need to test this for each provider.

It is also used in the save/restore state functions by each provider and that will still be
tested for each provider.

bq. Why not run locally?

No reason. Good catch.

I was thinking that it would be nice to collate results over a large number of tests. However
it would be better to do it once with a snapshot of the code. Using results from Travis for
each build will end up polluting the results over time if code changes are made to the core
providers.

My test for 1000 repeats of the test suite took about 4 hours on my laptop. So it is easy
to run overnight and get some reasonable statistics.

bq. Would you write it out in a new section of the user guide 

OK.  Sounds like tickets for the following:

- Improvement: Add details of RNG testing to the user guide. This outlines the the aim of
the test suite and provides a table of results for the number of times each RNG provider fails.
This can be run locally before a release, or when the core module is updated.

- Improvement: Refactor the tests for the core module to allow use of random seeds. Improve
robustness of the tests using targeted testing of the random sequence of each provider allowing
the test to fail under given statistical assumptions.


> 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)

Mime
View raw message