Prev: converting doubles to string
Next: Timer function
From: CY on 14 Dec 2009 14:20 My thought was to get the time between two events, then its OK (not great but OK), if you want the accurate, exact time on the millisecond/ micro/nano from the PC, how about checking on a NTP or a GPS app of some kind, they have nice clocks. ticks are nice to time an delta, a difference but not to get the real time, is your PC clock exact? to the microsecond, millisecond or even second? if using W32time it might be off a bit. I compared NTP to GPS and got 0.246 ms off. //CY
From: Gregory A. Beamer on 14 Dec 2009 14:58 "fniles" <fniles(a)pfmail.com> wrote in news:#uAhw0NfKHA.3916(a)TK2MSFTNGP05.phx.gbl: > In the above example, does 73 mean 73 miliseconds ? But, 1 seconds has > 1000 miliseconds, so that doesn't make sense. > > If the above function doesn't represent miliseond, what is the best > way to get the milliseconds ? It is actually centiseconds, or ten milliseconds. So 730 milliseconds is correct. Standard base 10 operation. You can get the millisecond from ticks, as well, but i tis trickier, as you have to have a point of reference. For this reason, ticks are more useful for time elapsed. For example, you might have a process you are timing. Module Module1 Sub Main() Dim timer1 As DateTime = DateTime.Now Dim i As Integer Dim d As Double 'Loop to waste some time For i = 1 To 1000000 d += i Next Dim timer2 As DateTime = DateTime.Now Dim timeElapsedInTicks As Long = timer2.Ticks - timer1.Ticks Dim timeElapsedInMilliseconds As Double = timeElapsedInTicks / 1000 Console.WriteLine("Ticks: {0}", timeElapsedInTicks) Console.WriteLine("Millseconds: {0}", timeElapsedInMilliseconds) Console.Read() End Sub End Module Peace and Grace, -- Gregory A. Beamer (MVP) Twitter: @gbworld Blog: http://gregorybeamer.spaces.live.com ******************************************* | Think outside the box! | *******************************************
From: CY on 14 Dec 2009 15:05 Did I die and got forced into the .NET world... can I leave that box...;)
From: fniles on 14 Dec 2009 15:19 OK, I will remember that in the future. Thank you. "mayayana" <mayaXXyana(a)rcXXn.com> wrote in message news:%23iuHqHPfKHA.4636(a)TK2MSFTNGP04.phx.gbl... >>> I did not see you used cross posting, will you be so kind in your >>> replies >>> remove the newsgroup VB general discussion. > >> Did you mean I shouldn't cross posting between vb.net and vb6 groups ? >> > > Exactly. They're 2 different things and have two > different groups. You referred to both VB6 code > and VB.Net code, but you're using one or the other. > (You can't mix and match them.) So you should be > posting in that group and limiting your question to > the code you're actually using. > >
From: fniles on 14 Dec 2009 15:21
Thank you very much for your help. "Gregory A. Beamer" <NoSpamMgbworld(a)comcast.netNoSpamM> wrote in message news:Xns9CE18DE4B17F0gbworld(a)207.46.248.16... > "fniles" <fniles(a)pfmail.com> wrote in > news:#uAhw0NfKHA.3916(a)TK2MSFTNGP05.phx.gbl: > >> In the above example, does 73 mean 73 miliseconds ? But, 1 seconds has >> 1000 miliseconds, so that doesn't make sense. >> >> If the above function doesn't represent miliseond, what is the best >> way to get the milliseconds ? > > It is actually centiseconds, or ten milliseconds. So 730 milliseconds is > correct. Standard base 10 operation. > > You can get the millisecond from ticks, as well, but i tis trickier, as > you have to have a point of reference. For this reason, ticks are more > useful for time elapsed. > > For example, you might have a process you are timing. > > Module Module1 > > Sub Main() > Dim timer1 As DateTime = DateTime.Now > > Dim i As Integer > Dim d As Double > > 'Loop to waste some time > For i = 1 To 1000000 > > d += i > > Next > > Dim timer2 As DateTime = DateTime.Now > > Dim timeElapsedInTicks As Long = timer2.Ticks - timer1.Ticks > Dim timeElapsedInMilliseconds As Double = timeElapsedInTicks / 1000 > > Console.WriteLine("Ticks: {0}", timeElapsedInTicks) > Console.WriteLine("Millseconds: {0}", timeElapsedInMilliseconds) > > Console.Read() > End Sub > > End Module > > Peace and Grace, > > -- > Gregory A. Beamer (MVP) > > Twitter: @gbworld > Blog: http://gregorybeamer.spaces.live.com > > ******************************************* > | Think outside the box! | > ******************************************* |