You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using faker-cxx to generate random data for databases. To test the library and make the generation more deterministic in general, it would be great to be able to provide an explicit seed for the pseudo-random number generator.
Currently, the seed is set with std::random_device:
Are you interested in adding this functionality? I'm happy to implement it.
Implementation-wise, I'm considering two alternatives. Let me know if I'm missing something—I'm still new to the code. :)
Providing a seed as parameter of the existing API functions. For example: faker::internet::email(seed=42). The disadvantage is that this would change the signature of all API functions and add an optional parameter. The advantage is that the rest of the code can stay the same (e.g., how RNGs are instantiated).
Using a single thread_local std::mt19937 instead of a static local for every function that needs a random engine, and adding a function to change its seed. This doesn't change the signature of any existing functions.
The text was updated successfully, but these errors were encountered:
I'm using faker-cxx to generate random data for databases. To test the library and make the generation more deterministic in general, it would be great to be able to provide an explicit seed for the pseudo-random number generator.
Currently, the seed is set with
std::random_device
:faker-cxx/include/faker-cxx/helper.h
Lines 41 to 42 in 1f76b3d
faker-cxx/include/faker-cxx/number.h
Line 37 in 1f76b3d
Are you interested in adding this functionality? I'm happy to implement it.
Implementation-wise, I'm considering two alternatives. Let me know if I'm missing something—I'm still new to the code. :)
faker::internet::email(seed=42)
. The disadvantage is that this would change the signature of all API functions and add an optional parameter. The advantage is that the rest of the code can stay the same (e.g., how RNGs are instantiated).std::mt19937
instead of a static local for every function that needs a random engine, and adding a function to change its seed. This doesn't change the signature of any existing functions.The text was updated successfully, but these errors were encountered: