VB .NET中最精确的计时?? [英] Most accurate timing in VB .NET??

查看:85
本文介绍了VB .NET中最精确的计时??的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VB中,我养成了使用API​​ QueryPerformanceCounter来实现最准确计时的习惯。


在VB .NET中,可以使用TotalMilliseconds和Ticks将时间转换为
毫秒。

这是否与使用QueryPerformanceCounter一样准确?


什么是在VB .NET中的分辨率?


例如:

Dim datEnd As Date

Dim datStart作为日期


datStart =现在

''在这里做东西

datEnd =现在

MsgBox((datEnd.Ticks - datStart.Ticks)/ 10000&" milliseconds(Ticks)&

vbCrLf& _

datEnd.Subtract(datStart ).TotalMilliseconds.ToStri ng()&"

毫秒(减去)")


-
http://www.standards.com/; 请参阅Howard Kaikow的网站。

In VB, I''ve developed the habit of using the API QueryPerformanceCounter to
achieve the most accurate timings.

In VB .NET, one can use TotalMilliseconds and Ticks to convert time to
milliseconds.
Is this as accurate as using the QueryPerformanceCounter?

What is the resolution of Now in VB .NET?

For example:

Dim datEnd As Date
Dim datStart As Date

datStart = Now
'' Do stuff here
datEnd = Now
MsgBox((datEnd.Ticks - datStart.Ticks) / 10000 & " milliseconds(Ticks)" &
vbCrLf & _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng() & "
milliseconds(Subtract)")

--
http://www.standards.com/; See Howard Kaikow''s web site.

推荐答案



http://msdn.microsoft.com/msdnmag/is...r/default.aspx


Ken

--- -----------

" Howard Kaikow" < KA **** @ standards.com>在消息中写道

news:uM ************* @ TK2MSFTNGP09.phx.gbl ...
Hi,

http://msdn.microsoft.com/msdnmag/is...r/default.aspx

Ken
--------------
"Howard Kaikow" <ka****@standards.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
在VB中,我''我们习惯使用API​​ QueryPerformanceCounter来实现最准确的计时。

在VB .NET中,可以使用TotalMilliseconds和Ticks将时间转换为
毫秒。
这是否与使用QueryPerformanceCounter一样准确?

现在在VB .NET中的解决方案是什么?

例如:

昏暗的datEnd作为日期
昏暗的datStart作为日期

datStart =现在
''做这里的东西
datEnd =现在
MsgBox(( datEnd.Ticks - datStart.Ticks)/ 10000&" milliseconds(Ticks)&
vbCrLf& _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng()&" ;
毫秒(减去)")

http://www.standards.com/; 请参阅Howard Kaikow的网站。
In VB, I''ve developed the habit of using the API QueryPerformanceCounter
to
achieve the most accurate timings.

In VB .NET, one can use TotalMilliseconds and Ticks to convert time to
milliseconds.
Is this as accurate as using the QueryPerformanceCounter?

What is the resolution of Now in VB .NET?

For example:

Dim datEnd As Date
Dim datStart As Date

datStart = Now
'' Do stuff here
datEnd = Now
MsgBox((datEnd.Ticks - datStart.Ticks) / 10000 & " milliseconds(Ticks)" &
vbCrLf & _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng() & "
milliseconds(Subtract)")

--
http://www.standards.com/; See Howard Kaikow''s web site.



Howard,

我通常使用QueryPerformanceCounter,因为我知道它有一个子b / b $毫秒的分辨率。另外它是PerformanceCounter

类的分辨率。


当Whidbey(VS.NET 2005)到来时,我们将有System.Diagnostics.Stopwatch

类,可以用作高分辨率计时器。据我所知,它将决定哪个更好(更高分辨率)DateTime.Ticks或

QueryPerformanceCount。

http://longhorn.msdn.microsoft.com /l...stopwatch.aspx
记住QueryPerformanceFrequency函数指示QueryPerformanceCounter函数的

分辨率是多少。刻度是固定的,分辨率为100纳秒,但据我所知,它们可能不会每100纳秒更新一次。

...


希望这有帮助

Jay


" Howard Kaikow" < KA **** @ standards.com>在消息中写道

news:uM ************* @ TK2MSFTNGP09.phx.gbl ...
Howard,
I normally use QueryPerformanceCounter as I understand it has a sub
millisecond resolution. Plus it is the resolution of the PerformanceCounter
classes.

When Whidbey (VS.NET 2005) arrives we will have System.Diagnostics.Stopwatch
class that you can use as a high resolution timer. I understand that it will
decides which is better (higher resolution) DateTime.Ticks or
QueryPerformanceCount.

http://longhorn.msdn.microsoft.com/l...stopwatch.aspx
Remember the QueryPerformanceFrequency function indicates what the
resolution of the QueryPerformanceCounter function is. Ticks are at a fixed
resolution of 100-nanosecond, however I understand they may not be updated
every 100-nanoseconds...

Hope this helps
Jay

"Howard Kaikow" <ka****@standards.com> wrote in message
news:uM*************@TK2MSFTNGP09.phx.gbl...
在VB中,我''我们养成了使用API​​ QueryPerformanceCounter
来获得最准确时序的习惯。

在VB .NET中,可以使用TotalMilliseconds和Ticks将时间转换为
毫秒。这是否与使用QueryPerformanceCounter一样准确?

VB在.NET中的解决方案是什么?

例如:

昏暗的datEnd作为日期
昏暗的datStart作为日期

datStart =现在
''做这里的东西
datEnd =现在
MsgBox((datEnd.Ticks - datStart.Ticks)/ 10000&" milliseconds(Ticks)&
vbCrLf& _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng()&"
毫秒(减去)")

http://www.standards.com/; 请参阅Howard Kaikow的网站。
In VB, I''ve developed the habit of using the API QueryPerformanceCounter to achieve the most accurate timings.

In VB .NET, one can use TotalMilliseconds and Ticks to convert time to
milliseconds.
Is this as accurate as using the QueryPerformanceCounter?

What is the resolution of Now in VB .NET?

For example:

Dim datEnd As Date
Dim datStart As Date

datStart = Now
'' Do stuff here
datEnd = Now
MsgBox((datEnd.Ticks - datStart.Ticks) / 10000 & " milliseconds(Ticks)" &
vbCrLf & _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng() & "
milliseconds(Subtract)")

--
http://www.standards.com/; See Howard Kaikow''s web site.



" Howard Kaikow" < KA **** @ standards.com> schrieb
"Howard Kaikow" <ka****@standards.com> schrieb
在VB中,我养成了使用API​​查询性能计数器来获得最准确计时的习惯。

在VB .NET中,我们可以使用TotalMilliseconds和Ticks将时间转换为毫秒。
这是否与使用QueryPerformanceCounter一样准确?

现在在VB .NET中的解决方案是什么?

例如:

Dim datEnd As Date
Dim datStart As Date

datStart = Now
''在这里做的东西 datEnd =现在
MsgBox((datEnd.Ticks - datStart.Ticks)/ 10000&"
毫秒(Ticks)& vbCrLf& _
datEnd.Subtract(datStart ).TotalMilliseconds.ToStri ng()&"
毫秒(减去)")
In VB, I''ve developed the habit of using the API
QueryPerformanceCounter to achieve the most accurate timings.

In VB .NET, one can use TotalMilliseconds and Ticks to convert time
to milliseconds.
Is this as accurate as using the QueryPerformanceCounter?

What is the resolution of Now in VB .NET?

For example:

Dim datEnd As Date
Dim datStart As Date

datStart = Now
'' Do stuff here
datEnd = Now
MsgBox((datEnd.Ticks - datStart.Ticks) / 10000 & "
milliseconds(Ticks)" & vbCrLf & _
datEnd.Subtract(datStart).TotalMilliseconds.ToStri ng() & "
milliseconds(Subtract)")


http://groups.google.com/groups?selm...TNGP10.phx.gbl

-

Armin


如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


http://groups.google.com/groups?selm...TNGP10.phx.gbl
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


这篇关于VB .NET中最精确的计时??的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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