vendredi 10 juin 2022

Why is random device creation expensive?

C++11 support pseudo-random number generation through <random> library. I've seen multiple books which mention that it is quite expensive to keep constructing and destroying std::random_device, std::uniform_int_distribution<>,
std::uniform_real_distribution<> objects and they recommend to keep a single copy of these objects in the application.

Why it is expensive to create/destroy these objects? And what exactly mean by expensive here? Is it expensive in terms of execution speed or executable size or any other thing?

Can someone please provide some explanation. Thanks.




Aucun commentaire:

Enregistrer un commentaire