Why is D significantly slower than C# in this instance?

WollyTheWombat WollyTheWombat at gmail.com
Wed Apr 12 23:09:34 UTC 2023


On Monday, 10 April 2023 at 21:18:59 UTC, Artjom wrote:
> I have written this simple bruteforce algorithm that finds max 
> sum of subsequence in some sequence, both in C# and D. And when 
> the size of array is 1000000 elements - D is 20 seconds lated. 
> Why?
> D code (algorithm):
> ..

By C#, I presume you mean dotnet.exe (and not csc.exe).

dotnet has many, many optimizations with regards to looping, and 
many more to come.

btw: 'quick JIT is not used for methods that contain loops'
https://learn.microsoft.com/en-us/dotnet/core/runtime-config/compilation

also:
'Loop optimizations can be surprising'
https://leveluppp.ghost.io/loop-optimizations-in-various-compilers/

As for D, well you have 3 different compilers to choose from, and 
various defaults, and various flags you can pass to them....so 
good luck with that ;-)

  - "The 80-20 rule is the dominating force driving the argument 
that premature tuning is a sin."



More information about the Digitalmars-d mailing list