Performance of Object.GetType()

前端 未结 7 1799
花落未央
花落未央 2020-12-05 03:44

We have lots of logging calls in our app. Our logger takes a System.Type parameter so it can show which component created the call. Sometimes, when we can be bothered, we

相关标签:
7条回答
  • 2020-12-05 04:43

    I doubt you are going to get a satisfying answer from SO on this subject. The reason being that performance, especially scenarios of this type, are highly application specific.

    Someone may post back with a quick stopwatch example of which would be faster in terms of raw miliseconds. But frankly that doesn't mean anything for your application. Why? It depends highly on the usage pattern around that particular scenario. For instance ...

    1. How many types do you have?
    2. How big are you methods?
    3. Do you do this for every method, or only big ones?

    These are just a few of the questions that will greatly alter the relevance of a straight time benchmark.

    0 讨论(0)
提交回复
热议问题