Are you interested in an optimization PR?

Issue #125 closed
Toni Marti created an issue

Hello,

Lately I've doing some performance profiling of an app at work where we use the great SQLiteNetExtensions.

At one of the app's processes, a big insert of records is done into the sqlite DB (there are several relationships between the entities and some of them have a bunch of TextBlobbed properties). About 7k entities are inserted.

So, when profiling the app, the profiler showed that a quite important percentage of time was spent inside the ReflectionExtensions class.

The proposed optimizations consists in caching the results from some .NET Reflection methods' calls like: - GetRuntimeProperty - GetRuntimeProperties - GetCustomAttribute - GetCustomAttributes - IsAssignableFrom

The only drawback I see from this change is in the case where code emission is done at runtime (then it would be bad to cache results for those methods as Types could be modified on-the-fly). But, as your library targets also iOS (and AFAIK code emission is forbidden for iOS' published apps), that should be fine anyway.

That being said, I did a quick test on our app (I cannot share the the test code by the moment, as we built a layer on top of SQLiteNetExtensions that I cannot share), that in our case reduces the mentioned process' time from about 7s to 5s, only introducing this cache change.

If you are interesed in the optimization or want to see how it would look, please just letme know and I'll be glad to do PR :-).

Comments (6)

  1. Guillermo Gutiérrez

    It would be a nice addition. I would leave it enabled by default but with the possibility of disabling it somehow, just in case it breaks something in any scenario.

  2. Toni Marti reporter

    Great! Will try to do the PR in about 1 or 2 weeks (very busy until then).

    Thanks a lot for your reply :)

  3. Toni Marti reporter

    Hi,

    Is there a way to execute the integration tests from a Windows PC or from an Android device? Or I do need to set up a new integration test project?

    (If iOS is the only option, I can live with that, but lately I'm mainly developing on PC)

  4. Log in to comment