Calculate the execution time of a method

后端 未结 7 880
小蘑菇
小蘑菇 2020-11-22 13:26

Possible Duplicate:
How do I measure how long a function is running?

I have an I/O time-taking method which c

7条回答
  •  自闭症患者
    2020-11-22 14:13

    StopWatch will use the high-resolution counter

    The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system support a high-resolution performance counter, then the Stopwatch class uses that counter to measure elapsed time. Otherwise, the Stopwatch class uses the system timer to measure elapsed time. Use the Frequency and IsHighResolution fields to determine the precision and resolution of the Stopwatch timing implementation.

    If you're measuring IO then your figures will likely be impacted by external events, and I would worry so much re. exactness (as you've indicated above). Instead I'd take a range of measurements and consider the mean and distribution of those figures.

提交回复
热议问题