Click to See Complete Forum and Search --> : Do someone know the VB speed issue?


kevin shen
July 30th, 2001, 11:37 PM
I try to use VB to trigger electrical board to do some work. But I care about the VB time consumption issue. I want the VB program to trigger board and let the board to generate a voltage something < 50us. Whatever, I just want to know how to calculate my VB program's time consumption. Maybe a rough time consumption number's also ok.

Thank you for your help!

Best Regards,

Kevin Shen

Cakkie
July 31st, 2001, 01:20 AM
If I get the question, you need to know how long your program does over a specific task, right?
If so, this is for you, if not, never mind

There are several ways to do this, depending on the required acuracy.
If you only need seconds, it can be done as easely using two dates, setting one to Now, when you start, setting the other to Now, when you end, and calculating the difference using the DateDiff function.

If you need Milliseconds, you can use the GetTickCount API, really easy to use. Use two longs, set the first at the start, the second at the end, and subtrackt them, you result will be the time elapsed in milliseconds. This will give you an result acurate about 10ms.

If you really really really need to go any further, you could use high frequency timers, accessible via API's. I've got a post on PlanetSourceCode (called 'Nick of time'). If you need it, just check it out.

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

cksiow
July 31st, 2001, 03:59 AM
I doubt you can get resolution of up to 50us in VB. if you do success, please inform us on how. if not, consider VC as alternative.



HTH

cksiow
http://vblib.virtualave.net - share our codes