Autofac vs TinyIoC

I recently added a resolver that is powered by TinyIoC to TinyMvvm because I got a request to do so because they said that performance was better. I have used Autofac for many years and I have never had any problems with it. But I decided to replace Autofac with TinyIoC in one app that I am working with right now, just to try to measure the difference.

What I did is that I logged 4 runs of the initializing code of the app for each IoC provider. I used the iOS simulator in debug mode. Here is the result:

Autofac (ms) TinyIoC (ms)
136 16
91 14
83 13
91 14

I was surprised that the difference was so big, we will probably have other numbers when running it in release mode, but I think that this test gives us a pretty good indication of what the performance is. I will definitely continue with TinyIoC in this app and I will also use it for new apps.

TinyIoC for TinyMvvm

There was an issue created for TinyMvvm regarding to use TinyIoC as the IoC-container. I had created an implementation of IResolver for Autofac. But now I decided to create one for TinyIoC too.

The implementation for it can be installed via the NuGet package, TinyMvvm.TinyIoC, https://www.nuget.org/packages/TinyMvvm.TinyIoC.

The code for setting up the container and the Resolver for the Sample project will look like this if you want to use TinyIoC:

TinyIoCContainer.Current.Register<INavigationHelper>(navigationHelper);

foreach (var type in appAssembly.ExportedTypes.Where(x => x.IsSubclassOf(typeof(ViewModelBase))))
{
    TinyIoCContainer.Current.Register(type);
}

foreach (var type in appAssembly.ExportedTypes.Where(x => x.IsSubclassOf(typeof(Page))))
{
    TinyIoCContainer.Current.Register(type);
}

Resolver.SetResolver(new TinyIoCResolver());