I've been working on a grid-based game and ran into a performance problem. Iterating over thousands of grid nodes caused noticeable lag and the profiler showed that my property getters we're the source of all evil.
public int xSize { get; set; } // 130 ms
public int xSize; // 30 ms
The profiler reported 130 ms for all calls of the backing field via get_xSize. I changed it to a public field and the time went down to 30 ms. That's more than 20% speed improvement only because of a simple getter.
How can this be? I thought that property getters are inlined by the JIT, but apparently this is not true, at least when testing with the Profiler in the Unity editor. Or might the test scenario be the problem and they are inlined in non-debug build?