我需要更换秒表以避免使用getter作为其属性.我将使用QueryPerformanceCounter实现它.我只需要其他任何东西.
任何人都可以提供代码snipet,以获得正确的滴答(1/10000毫秒)或任何其他小而稳定的值.
请注意我的服务器将时钟粒度设置为0.5毫秒(不确定它是否会影响QueryPerformanceCounter),但只是为了让您知道.
请注意 - 我不需要计时器.我只需要测量代码部分之间的时间间隔.
编辑:为了避免混淆我真的想知道什么是lpPerformanceCount在QueryPerformanceCounter的(出长lpPerformanceCount);
Mat*_*hew 10
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.gettimestamp.aspx
Stopwatch.GetTimestamp
您不必实例化Stopwatch对象,GetTimestamp无论其上下文如何都应返回刻度数.
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceCounter(out long lpPerformanceCount);
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceFrequency(out long lpFrequency);
Run Code Online (Sandbox Code Playgroud)
取自http://www.codeproject.com/Articles/2635/High-Performance-Timer-in-C
旧但它应该仍然有效
编辑:StopWatch实际使用的内部QueryPerformanceCounter,因此使用托管代码应提供相同的结果,具有更好的兼容性.
| 归档时间: |
|
| 查看次数: |
11495 次 |
| 最近记录: |