How do you measure code block (thread) execution time with multiple concurrent threads in .NET

后端 未结 4 2081
说谎
说谎 2021-01-01 01:13

Right now we just use something like this

        stopWatch.Start();            
        try
        {
            method();
        }
        finally
               


        
4条回答
  •  心在旅途
    2021-01-01 02:12

    Hmm, from Jon Skeet's answer to this question:

    Timing a line of code accurately in a threaded application, C#

    And also this article:

    http://lyon-smith.org/blogs/code-o-rama/archive/2007/07/17/timing-code-on-windows-with-the-rdtsc-instruction.aspx

    It seems like there's no simple way to do this.

提交回复
热议问题