473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

easy one

cj
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?
Mar 20 '06 #1
5 937
You could do something like:

label1.text = finishtime.Subtract(starttime).TotalSeconds.ToStri ng()

"cj" <cj@nospam.nospam> wrote in message
news:eL**************@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?

Mar 20 '06 #2
cj
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.ToStri ng()

"cj" <cj@nospam.nospam> wrote in message
news:eL**************@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?


Mar 20 '06 #3
Hello, cj,

Re:
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.

Also, be aware that using "Now" will become very inaccurate if the
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: 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.ToStri ng()

"cj" <cj@nospam.nospam> wrote in message
news:eL**************@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?


Mar 21 '06 #4
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/lib...sw(VS.80).aspx

Cor
Mar 21 '06 #5
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:
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/lib...sw(VS.80).aspx

Cor

Mar 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key"...
0
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size...
4
by: NBURGAN | last post by:
We are currently searching for a reporting tool with graphics for our end users who are using Oracle's standard edition. We are not using the Oracle's AS. The tool needs to be easy to use and...
19
by: Canon EOS | last post by:
Hi, I am really new in .net and pocket PC development. My background are purely C/C++/VC++. Have developed on Mobile Java for a year and felt completely insecure with it because all codes can...
8
by: Adam Clauss | last post by:
I have a folder containing many subfolders (and subfolders and....) all containing various .cs files. Is there any "easy" way to get them all added to the solution. Preferable would be that the...
2
by: Thomas | last post by:
Hi, I there anybody here that are designing applications with asp.net without html in aspx files? The problem is that aspx files is a dependency, and I would like to avoid having that...
5
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
13
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. :...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.