-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance Improvements Suggestion: Avoid locks
for Singletons and for RootScope
#169
Comments
The problem with Maybe |
This is the Startup benchmark for the code above. (From PR #168)
You are right, this change will cause a bigger startup timer and more allocation. |
Benchmark when using Singleton benchmark
Startup benchmark
Code private Jab.Performance.Basic.Singleton.Singleton1? _ISingleton1;
Jab.Performance.Basic.Singleton.ISingleton1 IServiceProvider<Jab.Performance.Basic.Singleton.ISingleton1>.GetService() => LazyInitializer.EnsureInitialized<Jab.Performance.Basic.Singleton.Singleton1>(ref this._ISingleton1); |
See: #168 (comment) |
locks
for Singletons and for RootScope
Currently, Jab uses
locks
to guarantee Singleton is only created one time.But alternative
Lazy<T>
is a faster alternative tolock
.Instead of
The JAB uses this code
We can see up to 35% of performance improvements.
See Details: Jab.Performance.Basic.Singleton.BasicSingletonBenchmark-report-github.md
The text was updated successfully, but these errors were encountered: