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

Alex Herbert commented on RNG-161:
----------------------------------

If recreating a RNG is too slow then I assume you are doing this very 
frequently, and as such you are not using many numbers from the RNG. In this 
case you should choose a RNG with a very small state such as SPLIT_MIX_64.

There is a performance test in the JMH examples module that compares creating a 
RNG with the constructor verses using RandomSource.create. If you already have 
a native seed then the difference is very small.

The fastest option through the RandomSource API and its equivalent would be:
{code:java}
Long seed = 123; // auto-boxing
UniformRandomProvider rng = RandomSource.create(RandomSource.SPLIT_MIX_64, 
seed);

// Equal to
UniformRandomProvider rng = new SplitMix64(seed);
{code}
Can you let me know your use case for reseeding where the speed is critical?

> 是否可以动态设置seed?
> -------------
>
>                 Key: RNG-161
>                 URL: https://issues.apache.org/jira/browse/RNG-161
>             Project: Commons RNG
>          Issue Type: Improvement
>          Components: client-api
>    Affects Versions: 1.3
>            Reporter: sun
>            Priority: Major
>
> Does Commons RNG can set the seed by method,isn't use 
> RandomSource.create,like random.setSeed() to set the seed ?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to