nicoriff / ORMi

A Light-ORM for accesing WMI
MIT License
210 stars 28 forks source link

Adding caching and performance improvements to the mapping and reflection #20

Open Frozenthia opened 4 years ago

Frozenthia commented 4 years ago

An immediate performance improvement would be to cache the PropertyInfo and setter as a delegate and the attributes for the target POCO, like how HyperDescriptor or FastMember or Fasterflect and the ORM Entity Framework does it.

I'm writing a library that is using some heavy hitting WMI queries and it's the mapping part that's adding a time delay. In my particular business case it goes from .002 to .05 for a particular operation. It's not bad from a human user perspective but it would be nice to keep it in the thousandths of a second range for the operation, because in my particular use case and code architecture I can't use an event watcher and have to run my operation in a tight blocking loop.

Although I don't know how to improve iterating over ManagementObjectCollection. That also adds a heavy delay but that's just WMI. Someone suggests using ManagementClass on MSDN. Also maybe analyzing the target POCO and removing irrelevant properties from the query automatically may be of some use, but the consumer can already handle that.