|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
easy oneI need to get the time it took for a process to run. It should be less
than a second but may be up to 5 seconds. I'm used to showing how many seconds something has taken by: starttime = now() .. .. finishtime = now() label1.text = DateDiff(DateInterval.Second, starttime, finishtime) but I don't think this will show me fractions of a second. How can I get it to display fractions of a second? You could do something like:
label1.text = finishtime.Subtract(starttime).TotalSeconds.ToString() Show quoteHide quote "cj" <cj@nospam.nospam> wrote in message news:eLGwkAGTGHA.2276@tk2msftngp13.phx.gbl... >I need to get the time it took for a process to run. It should be less >than a second but may be up to 5 seconds. > > I'm used to showing how many seconds something has taken by: > > starttime = now() > . > . > finishtime = now() > label1.text = DateDiff(DateInterval.Second, starttime, finishtime) > > but I don't think this will show me fractions of a second. How can I get > it to display fractions of a second? Sounds good, I'll give it a try. Thanks, Marina.
Marina Levit [MVP] wrote: Show quoteHide quote > You could do something like: > > label1.text = finishtime.Subtract(starttime).TotalSeconds.ToString() > > "cj" <cj@nospam.nospam> wrote in message > news:eLGwkAGTGHA.2276@tk2msftngp13.phx.gbl... >> I need to get the time it took for a process to run. It should be less >> than a second but may be up to 5 seconds. >> >> I'm used to showing how many seconds something has taken by: >> >> starttime = now() >> . >> . >> finishtime = now() >> label1.text = DateDiff(DateInterval.Second, starttime, finishtime) >> >> but I don't think this will show me fractions of a second. How can I get >> it to display fractions of a second? > > Hello, cj,
Re: >>> I need to get the time it took for a process to run. It should be Also, be aware that using "Now" will become very inaccurate if the >>> less than a second but may be up to 5 seconds. durations that you are measuring are less than 10-30 milliseconds. Depending on your need for accuracy, you might want to investigate the QueryPerformanceCounter API. Cheers, Randy cj wrote: Show quoteHide quote > Sounds good, I'll give it a try. Thanks, Marina. > > Marina Levit [MVP] wrote: > >> You could do something like: >> >> label1.text = finishtime.Subtract(starttime).TotalSeconds.ToString() >> >> "cj" <cj@nospam.nospam> wrote in message >> news:eLGwkAGTGHA.2276@tk2msftngp13.phx.gbl... >> >>> I need to get the time it took for a process to run. It should be >>> less than a second but may be up to 5 seconds. >>> >>> I'm used to showing how many seconds something has taken by: >>> >>> starttime = now() >>> . >>> . >>> finishtime = now() >>> label1.text = DateDiff(DateInterval.Second, starttime, finishtime) >>> >>> but I don't think this will show me fractions of a second. How can I >>> get it to display fractions of a second? >> >> >> Randy,
There is no accurate method on a Windows OS computer, which is not completely isolated from the outer-world, even not that API. Therefore I used in version 1.x forever environment.timerticks while there is now in 2.0 the stopwatch class http://msdn2.microsoft.com/en-us/library/ebf7z0sw(VS.80).aspx Cor Hi, Cor,
Thanks for the update and the link. Yes, there is no "absolute" accuracy -- even on a real-time OS. (And Windows doesn't even pretend to be real-time.) I guess that the real question is: "Is it accurate enough?". I think that the Now function might not be accurate enough for the needs of the OP -- but then again, it might. QueryPerformanceCounter will probably be accurate enough, but it is not available on all systems and there are a few subtleties involved in using it. It looks like StopWatch is basically a wrapper for whatever tool provides the greatest accuracy. (This is probably QueryPerformanceCounter on most systems, but TickCount on others). This is certainly easier than having to code for both possibilities like I had to do in VB6. I'm still using the earlier version. Too bad it's not available there too. Groetjes, Randy Cor Ligthert [MVP] wrote: Show quoteHide quote > Randy, > > There is no accurate method on a Windows OS computer, which is not > completely isolated from the outer-world, even not that API. > > Therefore I used in version 1.x forever environment.timerticks while there > is now in 2.0 the stopwatch class > > http://msdn2.microsoft.com/en-us/library/ebf7z0sw(VS.80).aspx > > Cor > >
COnverting CSV to XLS file
VB.NET Thread Garbage Collection Property and type Windows vb.net Datagrid Problems with Quotes in SQL queries in VB.Net Windows Thumbnail Control Regular Expressions Problem Failure Sending Mail exception with VS 2005 Microsoft VBScript compilation error '800a0400' Where did this come from: Microsoft\CStoVBConverter\Samples\Smart Client\ |
|||||||||||||||||||||||