使用刻度来测量绝对时间
我需要一种方法来非常精确地测量当前时间。刻度值似乎非常适合此操作,但获取它的最常见方法 (DateTime.Now
) 似乎具有相当宽松的容差(据我所知,大约约为 16 毫秒)。有一些示例使用 StopWatch 类来使用高分辨率计时器来测量增量,但没有使用这些相同的高分辨率计数器来测量当前时间作为刻度。
有没有什么方法可以获取比 DateTime.Now.Ticks 更精确的当前时间?
I need to way to get a very precise measurement of current time. The tick value seems to be perfect for this, but the most common way to get it (DateTime.Now
) seems to have a fairly loose tolerance (approx ~16ms from what I can tell). There are examples out there that use the StopWatch class to measure deltas using the high resolution timers, but nothing about using those same high resolution counters to measure the current time as ticks.
Is there any way to get the current time as ticks that is more precise than DateTime.Now.Ticks
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅之前的答案:
如何获取.NET / C# 中刻度精度的时间戳?
这个答案使用正在运行的
StopWatch
与DateTime.Now
结合使用来给出超准确的计时,但它有问题(请参阅所有评论)。See this earlier answer:
How to get timestamp of tick precision in .NET / C#?
This answer uses a running
StopWatch
in conjunction withDateTime.Now
to give hyper-accurate timing, but it has issues (see all the comments).经过相当多的研究后,我认为我已经完蛋了。虽然我可以使用建议的方法来跟踪经过的时间,但无法在机器之间进行比较。正如 MusiGenesis 评论的那样,拥有高精度计时器并不能真正帮助确定时间。
谢谢大家的解答
After a fair bit of research, I think that I am hosed. While I can use the methods suggested to track elapsed time, it can't be compared between machines. As MusiGenesis comments, having the high precision timer doesn't really help with what time it is.
Thanks for the answers all