什么是计时器滴答,使用Stopwatch.ElapsedTicks单位 [英] What are timer ticks, the unit used by Stopwatch.ElapsedTicks

查看:3399
本文介绍了什么是计时器滴答,使用Stopwatch.ElapsedTicks单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经以为,

  • Stopwatch.ElapsedTicks 等于
  • Stopwatch.Elapsed.Ticks
  • Stopwatch.ElapsedTicks was equal to
  • Stopwatch.Elapsed.Ticks.

但事实并非如此。而后者则是一个数字的100纳秒时间,前者使用一个神秘的单位,称为计时器滴答。我不知道那些是什么,以及为什么他们从测量常用的单位?

But it isn't. While the latter is a number of 100 nanoseconds periods, the former use a mysterious unit called timer ticks. I wonder what those are, and why are they different from the usual unit of measurement?

推荐答案

的文档

计数定时器秒表测量经过时间刻度底层定时器机制。如果安装的硬件和操作系统支持高分辨率的性能计数器,然后秒表类使用计数器测量经过时间。否则,秒表类使用系统计时器测量经过的时间。使用<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.frequency.aspx">Frequency和<一href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.ishighresolution.aspx">IsHighResolution字段,以确定秒表计时执行precision和解决方案。

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.

是的,那就是滴答痛过载意味着两个不同的东西:(

Yes, it's a pain that "ticks" is overloaded to mean two different things :(

我觉得这主要是因为秒表是给pretty的的性能计数器,它可以有不同的实现原始的看法是什么意思一个嘀。

I think it's basically because Stopwatch is giving a pretty "raw" view of a performance counter, which can have different implementations for what it means by a "tick".

这篇关于什么是计时器滴答,使用Stopwatch.ElapsedTicks单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆