jptrrs / SoftWarmBeds

A bed expansion for RimWorld.
https://steamcommunity.com/sharedfiles/filedetails/?id=1713295858
MIT License
0 stars 8 forks source link

Cache Hospitality reflections #11

Closed alattalatta closed 4 years ago

alattalatta commented 4 years ago

Fixes #10

This PR works mostly by caching every reflection info for Hospitality within the patch class, reducing performance overheads. For the field access (CompGuest#bed), see https://stackoverflow.com/a/38538377.

Results

RimWorld by Ludeon Studios 2020-05-03 오후 9_25_26 The very first patch call takes around 10ms, which is 97% reduction.

RimWorld by Ludeon Studios 2020-05-03 오후 9_32_15 Any subsequent calls takes even less time, highest being 2ms, and average, less than 1ms.

Tests were done in a small scale, so it would be a good idea to test it on your side too.

jptrrs commented 4 years ago

Hey, this is great! Thanks! I'll incorporate it ASAP.