Skip to content

Repository files navigation

.NET Matrix

Open the interactive .NET Matrix →

Evidence-based feature and performance comparisons for .NET libraries.

Dependency Injection

Rating

A gold, silver and bronze star for the first three places of every benchmark overview.

# Library 🥇 🥈 🥉 Won
1 Pure.DI 3 gold in Advanced, gold in Basic, gold in Prepare
2 Grace 2 silver in Advanced, silver in Basic
3 MvvmCross 1 silver in Prepare
4 DryIoc 1 bronze in Prepare
5 Singularity 1 bronze in Basic
6 Stashbox 1 bronze in Advanced

Benchmark overview

Performance and allocated memory are shown together. Lower values are better.

Dependency Injection Basic benchmark overview

Dependency Injection Advanced benchmark overview

Dependency Injection Prepare benchmark overview

Libraries

Autofac logo Autofac 9.3.1
A flexible inversion of control container for building extensible .NET applications.
Castle Windsor logo Castle Windsor 6.0.0
The Castle Project container, with bound lifestyles and Castle DynamicProxy interception.
Catel logo Catel 6.2.0
An MVVM application framework whose service locator and type factory perform constructor injection.
DryIoc logo DryIoc 5.4.3
A fast, small and feature-rich container with expression-compiled resolution and rich reuse options.
Faster.Ioc logo Faster.Ioc 5.0.0
A minimalistic container focused on the shortest possible resolve path.
Grace logo Grace 7.2.1
A container with a fluent registration model, per-object-graph lifestyles and decorator support.
Lamar logo Lamar 16.0.0
The successor to StructureMap, built around runtime code generation.
LightInject logo LightInject 7.1.0
A lightweight container with an ultra-small API surface and its own interception package.
Maestro logo Maestro 3.6.6
A small container with a fluent configuration API and pluggable activation interceptors.
Managed Extensibility Framework 2 logo Managed Extensibility Framework 2 10.0.10
The lightweight Managed Extensibility Framework composition engine shipped as System.Composition.
Microsoft Extensions Dependency Injection logo Microsoft Extensions Dependency Injection 10.0.10
The built-in .NET dependency injection container and its service collection abstractions.
MvvmCross logo MvvmCross 10.1.2
A cross-platform MVVM framework with its own inversion of control provider.
Ninject logo Ninject 3.3.6
A container built around fluent bindings, contextual conditions and pluggable extensions.
Pure.DI logo Pure.DI 2.5.2
A compile-time dependency injection framework that generates strongly typed compositions.
Simple Injector logo Simple Injector 5.6.0
A fast, opinionated dependency injection library that promotes explicit configuration and maintainable application design.
Singularity logo Singularity 0.18.0
An expression-tree based container that validates the whole object graph when the container is built.
Spring.NET logo Spring.NET 3.0.3
The Spring.NET application framework and its XML or code configured object factory.
Stashbox logo Stashbox 5.20.0
A fast container with per-request lifetimes, conditional registrations and child containers.
StructureMap logo StructureMap 4.7.1
A mature container with a fluent registry DSL, nested containers and decorators.
Unity logo Unity 5.11.10
The Unity container, offering per-resolve lifetimes and hierarchical child containers.
Visual Studio MEF logo Visual Studio MEF 17.13.41
The Visual Studio composition engine, a fast attribute-driven MEF implementation.
ZenIoc logo ZenIoc 1.0.1
A tiny container with compiled registrations, named resolution and nested containers.

Benchmark scenarios

01 · Singleton

Registers three singleton services and resolves each of them repeatedly. Every resolve of the same service must return the same instance.

Dependency Injection Singleton benchmark

02 · Transient

Registers three transient services and resolves each of them repeatedly. Every resolve must create a new instance, never reusing an earlier one.

Dependency Injection Transient benchmark

03 · PerResolve

Resolves an object graph that asks for the same dependency twice. Both requests inside one resolution share an instance, while the next resolution gets a new one.

Dependency Injection PerResolve benchmark

04 · Scoped

Resolves scoped services inside explicit scopes. One instance per scope, different instances across scopes, and scope-owned disposables are disposed when the scope ends.

Dependency Injection Scoped benchmark

05 · Combined

Resolves three roots that mix singleton and transient dependencies. The singleton is shared across every root while each transient dependency is distinct.

Dependency Injection Combined benchmark

06 · Complex

Registers and resolves three multi-level object graphs, checking that every nested dependency has the expected implementation type and lifetime.

Dependency Injection Complex benchmark

07 · Property

Resolves three roots that carry writable service properties. The container, or its intended property-injection extension, must assign them during activation.

Dependency Injection Property benchmark

08 · Generics

Registers one open generic service mapping and resolves roots closed over int, float and object. Registering every closed type separately does not count.

Dependency Injection Generics benchmark

09 · IEnumerable

Injects a sequence of five plugin implementations and requires it to be genuinely lazy: nothing is created until enumeration, and every enumeration yields new transients.

Dependency Injection IEnumerable benchmark

10 · Array

Resolves three roots that materialise their injected sequence of five plugins into an array while the root is being activated.

Dependency Injection Array benchmark

11 · Conditional

Gives each of three consumers a different implementation of one contract, chosen through the metadata, key, predicate or consumer-context mechanism of the library.

Dependency Injection Conditional benchmark

12 · Child Container

Creates a real nested child container that inherits the registrations of its parent and can add or override them without changing the parent.

Dependency Injection Child Container benchmark

13 · Interception With Proxy

Resolves a service through the interception or activation extension point of the library. The result must be a proxy whose interceptor proceeds to the real target.

Dependency Injection Interception With Proxy benchmark

14 · Prepare And Register

Measures creating the container and registering the whole prescribed graph, without resolving anything from it.

Dependency Injection Prepare And Register benchmark

15 · Prepare And Register And Simple Resolve

Measures the same setup as Prepare And Register, followed by a single resolve of one singleton root.

Dependency Injection Prepare And Register And Simple Resolve benchmark

About

Evidence-based feature and performance comparisons for .NET libraries.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages