How accurate is System.Diagnostics.Stopwatch?

后端 未结 8 2141
花落未央
花落未央 2020-11-30 10:55

How accurate is System.Diagnostics.Stopwatch? I am trying to do some metrics for different code paths and I need it to be exact. Should I be using stopwatc

8条回答
  •  离开以前
    2020-11-30 11:35

    If you want more precise timings. Take a look at the QueryPerformanceCounter. MSDN link for QueryPerformanceCounter. A neat implementation is given here. The example loads coredll.dll for CE, for Windows you should load the Kernel32.dll as stated in the MSDN documentation.

提交回复
热议问题