Strange counter-performance in an alternative `decimalLength9` function

Bruce Carneal bcarneal at gmail.com
Thu Feb 27 16:38:00 UTC 2020


On Thursday, 27 February 2020 at 15:29:02 UTC, Bruce Carneal 
wrote:
> big snip
TL;DR for the snipped: Unsurprisingly, different inputs will lead 
to different timing results.  The equi-probable values supplied 
by a standard PRNG differ significantly from an equi-probable 
digit input.  In particular, the PRNG input is much more 
predictable.

Note also that a uint PRNG will produce numbers that need 10 
decimal digits.  If my arithmetic is correct, you'll see "9 or 
better" out of a uint PRNG 97.79% of the time.  The 
predictability of the full set of inputs is, secondarily but 
importantly, also influenced by the ability of the branch 
predictor to ferret out combinations.

I lack confidence in my ability to reason from first principles 
when presented with a modern CPU branch predictor and a complex 
input.  Much easier for me to just run tests against various 
distributions that I think span the input and reason from the 
results.








More information about the Digitalmars-d-learn mailing list