-
Notifications
You must be signed in to change notification settings - Fork 76
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
How about MethodBase.GetCurrentMethod() performance #85
Comments
When profiling these approaches in this system I got:
// * Summary * BenchmarkDotNet=v0.13.0, OS=Windows 10.0.18363.1440 (1909/November2019Update/19H2)
So you are correct there yould be an improvement. |
Thank you for your contributions very much! |
Any solution for that? I just found the problem yesterday when benchmarking method call with and without this addin. Ten million calls without addin took 12ms, with almost 9000ms. When I added MethodBase.GetCurrentMethod to my "pure" method, the time was similiar to the time with addin. For me would be enough to be able prevent setting MethodExecutionArgs.Method at all as I can handle it myself in Attribute implementation (when needed). |
I managed to implement storing the method info in static fields to avoid using "Method.GetCurrentMethod". 841,12ns - 56,83ns = 784,29ns (v2.0.139) This is a speedup of 30x for aspect method invocation overhead or an reduction of 97% :-) Here are the benchmark numbers:
|
The benchmark project is here project |
@jerviscui can you verify the improved performance? |
Currently this optimization is only supported for closed types. |
Support for open generics was implemented in v2.0.144 Overhead for open generic methods is bigger because they can not efficently cached at compile time like closed generic or non-generic methods. // * Summary * BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1083 (2004/May2020Update/20H1)
|
You are amazing. 👍 I've been so busy with work and family lately. |
Looks great, thank you, I'll give it a try! Anyway, I still think that for special cases (eg. generics now) it would be fine if calling GetCurrentMethod could be switched off explicitly by decorator/attribute parameter... |
So you mean that you want to explicitly disable the method info because it is not used in the aspect itself? |
I see the weaved dll.
__var_.Method
use the static methodMethodBase.GetCurrentMethod()
get current method, this method performance is bad.Are there any other implementations? Just like
typeof(Type).GetMethod()
ortypeof(this).GetMethod()
?The text was updated successfully, but these errors were encountered: