R-T-B / TimberbornTerrainGenerator

A Terrain Generator for Beavers everywhere
MIT License
1 stars 2 forks source link

Performance of C# version is lacking... #3

Closed R-T-B closed 2 years ago

R-T-B commented 2 years ago

Map generation as of release 0.9.0 is both infinitely more flexible, and infinitely slower. C# is not a slower language than Python, it's much faster, and even though we are doing much more, we should try to optimize where we can.

This documents that effort. Starting metrics as of 0.9.0 can be found here:

https://github.com/R-T-B/TimberbornTerrainGenerator/blob/main/timings.md

R-T-B commented 2 years ago

0.9.2 improves this a lot, but it still needs work over time so leaving this open. Info on the timings doc.

R-T-B commented 2 years ago

It seems we could optimize by using native types instead of so many dictionaries for JSON. We should investigate this when possible.

Also, loop combining.

hytonhan commented 2 years ago

Hello! I found out that a major timesink is string handling in MapFileTools.GenerateArrayStrings(). I made some changes and created a Pull Request #6 that would improve performance significantly

R-T-B commented 2 years ago

Merged. Thank you very much! I will leave this open until I evaluate the dictionary situation, but this has massively helped things.

R-T-B commented 2 years ago

I'm not even sure I need to leave this open, lol, the new benches are in and that one change led to up to 677% improvements on 384x384 on modern hardware. We're talking 384x384 in under 1 minute for most modern PCs!

I'm still going to look at dictionary optimizations but holy crap...

https://github.com/R-T-B/TimberbornTerrainGenerator/blob/main/timings.md

R-T-B commented 2 years ago

Closing. It has been proven that the majority of the mod is now load times rather than the mod itself, thus work (and further benches) are now unneccesary).