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

Jacob Shtokolov jacob.100205 at gmail.com
Thu Apr 13 21:50:58 UTC 2023


On Wednesday, 12 April 2023 at 12:19:12 UTC, WebFreak001 wrote:
> On Monday, 10 April 2023 at 21:29:11 UTC, Artjom wrote:
>> [...]
> the logic here is wrong, `.total!"..."` already sums the 
> different units, you can just do `sw.peek.total!"hnsecs" / 
> 10_000_000.0` to get the total seconds as double.
>
> Otherwise this currently always doubled the time, since you 
> added the total (converted) seconds twice.

Or, he can just use

```d
void main()
{
     import std.datetime.stopwatch : benchmark;

     auto results = benchmark!(solveBruteforce)(1);
     results[0].writeln;
}
```


More information about the Digitalmars-d mailing list