Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Garbage from subscribing to collision events
#18
(18-12-2017, 06:36 PM)josemendez Wrote: Wow! thanks for such thorough profiling Sonrisa.

As I suspected (thank you C# godsÁngel) the compiler optimizes the function call away at runtime and performance is roughly the same both for the raw access/[] operator methods.

The new code being slightly slower (0.02 ms) could be explained by the extra getter used (.Data) to get to the raw array. Calling this once at the top of the OnCollision callback, instead of calling it inside the loop, might scrape a tiny lil bit of performance back. But I'd be surprised if the compiler didn't do this automatically.

If you're ok with it, I'd say case closed. The benefit of not having GC spikes outweights these tiny performance differences (and in heavier scenes with lots of contacts it is still faster for me).

Agreed, case closed on this. In almost all situations the benefit of removing GC far outweighs the microperformance gain. I think this would really shine in mobile where GC is likely even more important. I'm still not 100% convinced the original code should be removed from future updates, as a suggestion, maybe a toggle would be better? It was slightly unnerving to see my fps in editor go from 120 to 70 on a more complex scene. However, I leave the design/organization to the better minds at Obi. I appreciate all the help!
Reply


Messages In This Thread
RE: Garbage from subscribing to collision events - by writer51 - 18-12-2017, 06:42 PM