Why is
var random = new Random();
random.Next(0 /* or any other positive value */, int.MaxValue);
about 1.5 times as fast as:
random.Next(-1, int.MaxValue);
How does the .NET Framework (4.7.2) implement this functions? Shouldn't they have about the same performance?
(performance measured by generating 10M values in a loop)
Edit: Is it possible that the range between -1 and int.MaxValue is too big so it has to generate two values internally? Because I don't see the behavior when generating between -1 and int.MaxValue-1
Aucun commentaire:
Enregistrer un commentaire