Hello dear friends,
I have ported my minecraft clone to the Monogame framework and realized some little perfomance issues : Chiefly while generating the world; in XNA the generation for a 13x13 chunk-map (each chunk has a width and depth of 13 and a height of 256)
takes 0.67 seconds, in Monogame 2 !.
How can I optimize the code to achieve the same speed as in XNA?
I thank you in advance.
Post scriptum: The FPS is mostly similar(in comparison to xna), just the world-generation takes a “bit” longer.
You can analyze your code using a .NET performance profiler (such as Visual Studio, Redgate ANTS Performance Profiler, Jetbrains dotTrace, …) and find out how long each function is taking.
I suggest you create a performance profile of the XNA app and the MonoGame app and compare the profiles. If a MonoGame function is causing the slow down, you can create a new issue on Github.
I am sorry, my Visual Studio is only giving me these kind of information and analyzing processes.
The Monogame-versions are these with the titel “MinecraftCloneMonogame”.
Looks like you only got the memory profile for the MonoGame build… that won’t help us. Like in your XNA build you need to look at the performance profile.
You should really avoid calling GetData on any graphics resource… you are literally copying data back from GPU memory to CPU memory. This is not very fast at all.
We could maybe optimize things a bit more there, but DX11 is different from DX9 and it may just never be able to get the same performance as XNA with this. Even then… it will always be slower than already having this data in CPU memory… regardless of XNA or MonoGame.