-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
I've been working on a Maze Generator as a personal hobby project for a number of years now and always try to keep it up to date with the latest .NET stuff.
Yesterday .NET 7.0 came out and I immediately upgraded my project to see if it would bring performance benefits.
Sadly the opposite seems to be true.
On my main computer:
Processor: AMD 5950x
RAM: 128GB
Operating System: Windows 11
dotnet SDK: 7.0.100
On my laptop:
Processor: Intel Core i7 12700H
RAM: 128GB
Operating System: Windows 11
dotnet SDK: 7.0.100
I didn't make screenshots but the times went from:
Before: 2.1 seconds
After: 2.6 seconds
My code
The following file contains the implementation of the Algorithm I'm using. Besides the code in this file I'm using my own implementation of a Random generator + my own implementation of a BitArray to store the maze.
Reproduce
I've created 2 branches that show the difference quite easily by simply running the ConsoleApp:
dotnet 6:
https://github.com/devedse/DeveMazeGeneratorCore
dotnet 7:
https://github.com/devedse/DeveMazeGeneratorCore/tree/dotnet7
Additional info
Even running them at the same time side by side you can clearly see the performance difference:

Some more research and doing a NativeAOT compilation to see if this differs (it does?!?)
I did some more investigation and compiled my code like this:
DeveMazeGeneratorCore\DeveMazeGeneratorCore.ConsoleApp> dotnet publish -r win-x64 -c Release -p:PublishReadyToRun=true -p:PublishSingleFile=true --self-contained
This results in 2 exe files that for some reason also differ quite significantly in performance:
-
DeveMazeGeneratorCore.ConsoleApp\bin\Release\net7.0\win-x64\DeveMazeGenerator.ConsoleApp.exe (9.265kb):

-
DeveMazeGeneratorCore.ConsoleApp\bin\Release\net7.0\win-x64\publish\DeveMazeGenerator.ConsoleApp.exe (100.360kb):

The second file (in the publish folder) does seem to go slightly faster then the original .NET 6.0.

