200-600x slower Dlang performance with nested foreach loop

Steven Schveighoffer schveiguy at gmail.com
Tue Jan 26 19:49:15 UTC 2021


On 1/26/21 12:40 PM, methonash wrote:
> My first attempt to solve this problem space used a small Perl program 
> to perform steps 1 through 3, which would then pipe intermediate output 
> to a small Dlang program handling only step #4 using dynamic arrays (no 
> use of AAs) of ubyte[][] with use of countUntil().
> 
> The Dlang code for the nested foreach block above is essentially 
> near-identical between my two Dlang implementations. Yet, the second 
> implementation--where I'm trying to solve the entire problem space in 
> D--has absolutely failed in terms of performance.
> 
> Perl+D, ubyte[][], countUntil() :: under 2 seconds
> only D, string[], indexOf() :: ~6 minutes
> only D, ubyte[][], countUntil() :: >20 minutes

Maybe try a different approach.

Replace the perl code with D, and still have it output to the same small 
D program that processes the results. It seems from your description 
that everything is "identical" that if your conclusions are correct, it 
should be at least as fast as the Perl+D version.

But I think you are missing something else.

-Steve


More information about the Digitalmars-d-learn mailing list