Strange counter-performance in an alternative `decimalLength9` function
Bruce Carneal
bcarneal at gmail.com
Wed Feb 26 20:44:31 UTC 2020
On Wednesday, 26 February 2020 at 19:44:05 UTC, Bruce Carneal
wrote:
> On Wednesday, 26 February 2020 at 13:50:11 UTC, Basile B. wrote:
>> On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B.
>> wrote:
>> ...
>> foreach (i; 0 .. count)
>> sum += funcs[func](i);
>
> The input stream is highly predictable and strongly skewed
> towards higher digits.
>
> The winning function implementation lines up with that
> distribution. It would not fare as well with higher entropy
> input.
Using sorted equi-probable inputs (N 1 digit numbers, N 2 digit
numbers, ...) decimalLength9_0 beats a simple branchless
implementation by about 10%.
After shuffling the input, branchless wins by 2.4X (240%).
More information about the Digitalmars-d-learn
mailing list