Coffeehouse Post

Single Post Permalink

View Thread: is managed code faster than native?
  • User profile image

    , BitFlipper wrote

    One thing I found in both C# and C++ (STL), is to stay away from enumerators (foreach and begin()). Instead use simple integer loop indexing. There is a measurable performance drop in both cases when using enumerators.

    Where performance doesn't matter, using an enumerator is fine.

    If the use of an SDL enumerator rather than an integer indexer is the thing tanking your performance, then something has gone so far wrong in your app it's unreal.

    My suggestion is that you benchmark your code before optimising it. Optimise only the bits that are actually in your hotpath, and choose algorithms that can be easily parallelized or which have known correct library implementations with lower big-Ohs to the ones you're using.

    The rest of your code should focus on being readable and correct instead of being fast.