Is there a way to count the number of IL instructions executed?

后端 未结 5 619
萌比男神i
萌比男神i 2021-01-06 06:19

I want to do some benchmarking of a C# process, but I don\'t want to use time as my vector - I want to count the number of IL instructions that get executed in a particular

5条回答
  •  醉话见心
    2021-01-06 07:12

    You could use ICorDebug which has a managed interface. Chuck a break point at the beginning of the method and programmaticly step through the code till it leaves the method.

    However, I am not sure how useful the metric will be, people tend to use time for this kind of stuff. Some IL instructions are more expensive than others.

提交回复
热议问题