PerformanceCounter的C#替换

时间:2009-02-13 13:56:03

标签: c# .net performancecounter

我想知道是否存在用于精确时间测量的“.net集成”解决方案(如功能的执行时间)?目前我正在使用Kernel32中的PerformanceCounters。

    [DllImport("Kernel32.dll")]
    private static extern bool QueryPerformanceCounter(
        out long lpPerformanceCount);

    [DllImport("Kernel32.dll")]
    private static extern bool QueryPerformanceFrequency(
        out long lpFrequency);

2 个答案:

答案 0 :(得分:12)

The Stopwatch是一个高分辨率框架计时器类(可能包含该api)。

答案 1 :(得分:3)