For logging purposes, some methods in our application include the following line:
Dim Log As ILog = GetLog(Reflection.MethodBase.GetCurrentMethod().DeclaringType)
I have what might be described as an irrational fear of reflection, which I try to keep in check. However, calls like this in methods that are executed potentially a hundred times a second concern me. I don't know as much as I should about reflection; but from looking briefly over the documentation, it looks to me like I could replace the following with:
Dim Log As ILog = GetLog(Me.GetType())
My question is three-fold:
- Does
Me.GetType()
actually return the sameType
asGetCurrentMethod().DeclaringType
? - Does
Me.GetType()
actually do anything differently fromGetCurrentMethod().DeclaringType
, or is it doing the same thing under the hood? - Should I not even be worried about this at all? Performance is critical in this application; the program runs fine, but the nature of our business is such that if we can shave off even a few microseconds here and there, that is useful.