-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve performance of filters (2-3 x faster) #1779
Conversation
Current coverage is 80% (diff: 79%)@@ master #1779 diff @@
==========================================
Files 277 277
Lines 17780 17825 +45
Methods 2785 2787 +2
Messages 0 0
Branches 2024 2032 +8
==========================================
+ Hits 14306 14333 +27
- Misses 3022 3040 +18
Partials 452 452
|
Impressive! |
Any idea how much faster? |
Results from logging 2.000.000 message (Size 64 bytes) using the following NLog-config (using NLogPerformance):
|
\0/ |
|
||
// non-instance for static method, or ((TInstance)instance) | ||
var instanceCast = methodInfo.IsStatic ? null : | ||
Expression.Convert(instanceParameter, methodInfo.ReflectedType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another netstandard challenge, methodInfo.ReflectedType
isn't there. Any idea how to fix it? I dunno what the ReflectedType
is in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that we should be using DeclaringType instead of ReflectedType. Opened #1865
ExpressionFilters - Compile MethodInfo into LateBoundMethod-delegate
Using the technique from Nate Kohari:
https://web.archive.org/web/20140226131612/http://kohari.org/2009/03/06/fast-late-bound-invocation-with-expression-trees
Then the MethodInfo is compiled into a delegate, that is much faster. Manual handling of default-/optional-parameters are required.
This change is