Connecting Tech Pros Worldwide Forums | Help | Site Map

Record milliseconds

Mark
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi all,
is there a function that will record milliseconds? Something along the
line of Now() perhaps?

This will be recorded into a text file rather than a table.

TIA,

Mark



Angelo
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Record milliseconds


mark, this is a common request but not a commonly known solution. There
are 2 ways to attack this problem.

1) u can use the system clock and a function GetTickCount Lib
"kernel32"() to get the time elapsed since midnight. This time is
returned in milliseconds. and then u work from there. i really can't
comment more on this method without data def.
2) u can convert ur time to milliseconds by hard coding it. That is,
convert all ur hours to milliseconds, then minutes, then seconds and
then sum them all. this method is bulky though and the first is the
preferred road to take.

u can some more info here.
http://www.developerfusion.com/forums/topic-26515
and here http://www.tek-tips.com/faqs.cfm?fid=2292

good luck.

jimfortune@compumarc.com
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Record milliseconds


Angelo wrote:[color=blue]
> mark, this is a common request but not a commonly known solution. There
> are 2 ways to attack this problem.
>
> 1) u can use the system clock and a function GetTickCount Lib
> "kernel32"() to get the time elapsed since midnight. This time is
> returned in milliseconds. and then u work from there. i really can't
> comment more on this method without data def.[/color]

IIRC, the system clock, although returning something that looks like it
is accurate to a millisecond, is quite a bit less accurate in practice.
The numbers aren't too far off but they can vary considerably within
the second depending on what the OS is doing at the moment. I'm not
talking about a slowing clock setting due to a dying battery on the
motherboard. I wouldn't count on the system clock being closer than
about .05 second to the actual fraction of a second. In short, the
clock ticks themselves are not perfectly regular so don't assume you're
getting perfect accuracy in spite of those extra decimals you see. I
realize this seems strange considering the extraordinary regularity of
solid-state timers but I read about the system clock variations
somewhere when I was doing some data acquisition. I don't have the
reference anymore. YMMV.

James A. Fortune

Chuck
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Record milliseconds


On 23 Jun 2005 11:00:12 -0700, jimfortune@compumarc.com wrote:
[color=blue]
>Angelo wrote:[color=green]
>> mark, this is a common request but not a commonly known solution. There
>> are 2 ways to attack this problem.
>>
>> 1) u can use the system clock and a function GetTickCount Lib
>> "kernel32"() to get the time elapsed since midnight. This time is
>> returned in milliseconds. and then u work from there. i really can't
>> comment more on this method without data def.[/color]
>
>IIRC, the system clock, although returning something that looks like it
>is accurate to a millisecond, is quite a bit less accurate in practice.
>The numbers aren't too far off but they can vary considerably within
>the second depending on what the OS is doing at the moment. I'm not
>[/color]
And that's the problem. The clock itself is reasonably accurate. However,
there is always some delay between when you ask for the time and when the
computer gets around to actually giving it to you. The problem is that the
deley is an unmeasurable variable. "depending on what the OS is doing at the
moment." Chuck.
[color=blue]
>talking about a slowing clock setting due to a dying battery on the
>motherboard. I wouldn't count on the system clock being closer than
>about .05 second to the actual fraction of a second. In short, the
>clock ticks themselves are not perfectly regular so don't assume you're
>getting perfect accuracy in spite of those extra decimals you see. I
>realize this seems strange considering the extraordinary regularity of
>solid-state timers but I read about the system clock variations
>somewhere when I was doing some data acquisition. I don't have the
>reference anymore. YMMV.
>
>James A. Fortune[/color]

Hank
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Record milliseconds


James,
What a great tip! I use the tick count in my Progress Bar
routine to tell the user how much time left, 10, 9, 8, seconds, et
cetera which I superimpose on the Bar. I do this by measuring the
time since the last Progress Bar update. I had always noticed how much
it jumped around, even though I average the last 50 elapsed times.
This probably explains that phenomena.
Hank Reed

Chuck
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Record milliseconds


On 24 Jun 2005 06:49:07 -0700, "Hank" <hankrunner@aol.com> wrote:
[color=blue]
>James,
> What a great tip! I use the tick count in my Progress Bar
>routine to tell the user how much time left, 10, 9, 8, seconds, et
>cetera which I superimpose on the Bar. I do this by measuring the
>time since the last Progress Bar update. I had always noticed how much
>it jumped around, even though I average the last 50 elapsed times.
> This probably explains that phenomena.
>Hank Reed[/color]
I'm not so sure. Whole seconds should not be a problem. Miliseconds and even
hundredths are problems.

Chuck
Closed Thread