commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex D Herbert (JIRA)" <>
Subject [jira] [Commented] (RNG-78) ThreadLocalRandomSource
Date Sun, 03 Mar 2019 22:28:00 GMT


Alex D Herbert commented on RNG-78:

Updated the benchmark to add a raw implementation using {{ThreadLocal<UniformRandomProvider>}}.
This shows how the factory method compares with a custom implementation:

So using the factory method to get a RNG and generate 1 value is only marginally slower than
using a custom ThreadLocal<UniformRandomProvider>. This shows that the utility class
is providing almost optimal performance and avoids an end user having to write this boiler
plate code for any {{RandomSource}} they would like to use.


> ThreadLocalRandomSource
> -----------------------
>                 Key: RNG-78
>                 URL:
>             Project: Commons RNG
>          Issue Type: New Feature
>          Components: simple
>    Affects Versions: 1.3
>            Reporter: Alex D Herbert
>            Assignee: Alex D Herbert
>            Priority: Minor
>          Time Spent: 50m
>  Remaining Estimate: 0h
> Implement a helper class that can provide thread-local {{UniformRandomProvider}} instances. 
> This can be used as an equivalent of {{ThreadLocalRandom}}:
> {code:java}
> // c.f.
> Random random = ThreadLocalRandom.current();
> // Access a thread-safe random number generator
> UniformRandomProvider rng = 
>     ThreadLocalRandomSource.current(RandomSource.SPLIT_MIX_64);
> {code}

This message was sent by Atlassian JIRA

View raw message