Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Mersenne Twister engine when C++11 is available #2159

Merged

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Oct 12, 2021

Use the Mersenne Twister engine if ENABLE_CXX=ON instead of a random_device directly.

std::random_device is usually slower and may be deterministic. E.g. see this for more details.

An example run of the SyncRandom.GenRandomInt unit test generating 4560000 samples took 72 ms with random_device instead of 54 ms with mt19937.

@maxsharabayko maxsharabayko added Type: Maintenance Work required to maintain or clean up the code [core] Area: Changes in SRT library core labels Oct 12, 2021
@maxsharabayko maxsharabayko added this to the v1.4.5 milestone Oct 12, 2021
@maxsharabayko maxsharabayko changed the title Use the Mersenne Twister engine when STDCXX_SYNC is enabled Use the Mersenne Twister engine when C++11 is available Oct 12, 2021
instead of the std::random_device.
Fixed max value probability for the default (C++03) rand().
@maxsharabayko maxsharabayko merged commit fa1c373 into Haivision:master Oct 13, 2021
@maxsharabayko maxsharabayko deleted the develop/rand_mersenne_twister branch October 13, 2021 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant