PC Review


Reply
Thread Tools Rate Thread

How do I get an accurate time in CF?

 
 
Jim H
Guest
Posts: n/a
 
      22nd Sep 2004
I need to keep the time with data that is coming into my app. On the
desktop I use DateTime.Now.Ticks to get a time stamp down to the thousandths
of a second. On the desktop is gave me numbers like this:
632312367562450276
632312367562606512

On the PPC I get numbers like this:
632314491430000000
632314491500000000

The precision is not there. The numbers I get from the PPC have gaps
anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
seconds. Is there a way to get a more accurate time stamp from PPC?

Thanks,
jim


 
Reply With Quote
 
 
 
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      22nd Sep 2004
"Gaps" I'm not sure about but, as you know, the hardware inside a PPC is not
the same as the hardware inside a PC, including timers. If you P/Invoke to
GetTickCount(), that will return a number of timer ticks since startup.
Since it's a 32-bit value, it will roll over periodically and you'll have to
handle that, but it should give you one tick per ms (0.001). It's possible
that QueryPerformanceCounter() would also work on PPC (I don't have any PPC
devices to try it). That might give you a higher-resolution counter.

What is it that you are trying to do with this time? Calculate a really
accurate time-of-day? Or measure a delta between two events?

Paul T.

"Jim H" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I need to keep the time with data that is coming into my app. On the
>desktop I use DateTime.Now.Ticks to get a time stamp down to the
>thousandths of a second. On the desktop is gave me numbers like this:
> 632312367562450276
> 632312367562606512
>
> On the PPC I get numbers like this:
> 632314491430000000
> 632314491500000000
>
> The precision is not there. The numbers I get from the PPC have gaps
> anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
> seconds. Is there a way to get a more accurate time stamp from PPC?
>
> Thanks,
> jim
>



 
Reply With Quote
 
Jim H
Guest
Posts: n/a
 
      22nd Sep 2004
I'm trying to measure between 2 events. I'm reading from a connection and I
need to record the time between the packets of data I get back.

DateTime.Now.Ticks is supposed to be the tick count. According to the
documentation:
The value of this property is the number of 100-nanosecond intervals that
have elapsed since 12:00 A.M., January 1, 0001.

But the values coming back from the PPC seem to only be accurate to the ten
millions. All the numbers that came back had 7 0's after them. No number
was any more accurate than that.

Thanks,
jim


"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
wrote in message news:%(E-Mail Removed)...
> "Gaps" I'm not sure about but, as you know, the hardware inside a PPC is
> not the same as the hardware inside a PC, including timers. If you
> P/Invoke to GetTickCount(), that will return a number of timer ticks since
> startup. Since it's a 32-bit value, it will roll over periodically and
> you'll have to handle that, but it should give you one tick per ms
> (0.001). It's possible that QueryPerformanceCounter() would also work on
> PPC (I don't have any PPC devices to try it). That might give you a
> higher-resolution counter.
>
> What is it that you are trying to do with this time? Calculate a really
> accurate time-of-day? Or measure a delta between two events?
>
> Paul T.
>
> "Jim H" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I need to keep the time with data that is coming into my app. On the
>>desktop I use DateTime.Now.Ticks to get a time stamp down to the
>>thousandths of a second. On the desktop is gave me numbers like this:
>> 632312367562450276
>> 632312367562606512
>>
>> On the PPC I get numbers like this:
>> 632314491430000000
>> 632314491500000000
>>
>> The precision is not there. The numbers I get from the PPC have gaps
>> anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
>> seconds. Is there a way to get a more accurate time stamp from PPC?
>>
>> Thanks,
>> jim
>>

>
>



 
Reply With Quote
 
Ilya Tumanov [MS]
Guest
Posts: n/a
 
      22nd Sep 2004
While Ticks are in 100 ns units, actual resolution depends on hardware and
is about 50 ms in most cases.

You can P/Invoke this to get higher precision:

[DllImport("coredll.dll")]
private static extern bool QueryPerformanceCounter(out long count);

[DllImport("coredll.dll")]
private static extern bool QueryPerformanceFrequency(out long
frequency);

This is optional, but implemented on most PPC. Resolution is usually 1 uS.
Call QueryPerformanceFrequency() first to make sure it's implemented and to
find out the actual resolution.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
> From: "Jim H" <(E-Mail Removed)>
> Subject: How do I get an accurate time in CF?
> Date: Wed, 22 Sep 2004 15:58:22 -0400
> Lines: 18
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
> X-RFC2646: Format=Flowed; Original
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
> Message-ID: <#(E-Mail Removed)>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: crlspr-24.233.164.226.myacc.net 24.233.164.226
> Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
> Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.compactframework:61812
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
>
> I need to keep the time with data that is coming into my app. On the
> desktop I use DateTime.Now.Ticks to get a time stamp down to the

thousandths
> of a second. On the desktop is gave me numbers like this:
> 632312367562450276
> 632312367562606512
>
> On the PPC I get numbers like this:
> 632314491430000000
> 632314491500000000
>
> The precision is not there. The numbers I get from the PPC have gaps
> anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
> seconds. Is there a way to get a more accurate time stamp from PPC?
>
> Thanks,
> jim
>
>
>


 
Reply With Quote
 
Chris Tacke, eMVP
Guest
Posts: n/a
 
      22nd Sep 2004
Environment.TickCount is what you want. The Perf counters can give even
higher resolution.

-Chris


"Jim H" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to measure between 2 events. I'm reading from a connection and

I
> need to record the time between the packets of data I get back.
>
> DateTime.Now.Ticks is supposed to be the tick count. According to the
> documentation:
> The value of this property is the number of 100-nanosecond intervals that
> have elapsed since 12:00 A.M., January 1, 0001.
>
> But the values coming back from the PPC seem to only be accurate to the

ten
> millions. All the numbers that came back had 7 0's after them. No number
> was any more accurate than that.
>
> Thanks,
> jim
>
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> wrote in message news:%(E-Mail Removed)...
> > "Gaps" I'm not sure about but, as you know, the hardware inside a PPC is
> > not the same as the hardware inside a PC, including timers. If you
> > P/Invoke to GetTickCount(), that will return a number of timer ticks

since
> > startup. Since it's a 32-bit value, it will roll over periodically and
> > you'll have to handle that, but it should give you one tick per ms
> > (0.001). It's possible that QueryPerformanceCounter() would also work

on
> > PPC (I don't have any PPC devices to try it). That might give you a
> > higher-resolution counter.
> >
> > What is it that you are trying to do with this time? Calculate a really
> > accurate time-of-day? Or measure a delta between two events?
> >
> > Paul T.
> >
> > "Jim H" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> >>I need to keep the time with data that is coming into my app. On the
> >>desktop I use DateTime.Now.Ticks to get a time stamp down to the
> >>thousandths of a second. On the desktop is gave me numbers like this:
> >> 632312367562450276
> >> 632312367562606512
> >>
> >> On the PPC I get numbers like this:
> >> 632314491430000000
> >> 632314491500000000
> >>
> >> The precision is not there. The numbers I get from the PPC have gaps
> >> anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
> >> seconds. Is there a way to get a more accurate time stamp from PPC?
> >>
> >> Thanks,
> >> jim
> >>

> >
> >

>
>



 
Reply With Quote
 
=?Utf-8?B?c2hhcGlq?=
Guest
Posts: n/a
 
      23rd Sep 2004
Chris has given you the correct answer (Environment.TickCount) for timing
milliseconds.

"Chris Tacke, eMVP" wrote:

> Environment.TickCount is what you want. The Perf counters can give even
> higher resolution.
>
> -Chris
>
>
> "Jim H" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I'm trying to measure between 2 events. I'm reading from a connection and

> I
> > need to record the time between the packets of data I get back.
> >
> > DateTime.Now.Ticks is supposed to be the tick count. According to the
> > documentation:
> > The value of this property is the number of 100-nanosecond intervals that
> > have elapsed since 12:00 A.M., January 1, 0001.
> >
> > But the values coming back from the PPC seem to only be accurate to the

> ten
> > millions. All the numbers that came back had 7 0's after them. No number
> > was any more accurate than that.
> >
> > Thanks,
> > jim
> >
> >
> > "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> > wrote in message news:%(E-Mail Removed)...
> > > "Gaps" I'm not sure about but, as you know, the hardware inside a PPC is
> > > not the same as the hardware inside a PC, including timers. If you
> > > P/Invoke to GetTickCount(), that will return a number of timer ticks

> since
> > > startup. Since it's a 32-bit value, it will roll over periodically and
> > > you'll have to handle that, but it should give you one tick per ms
> > > (0.001). It's possible that QueryPerformanceCounter() would also work

> on
> > > PPC (I don't have any PPC devices to try it). That might give you a
> > > higher-resolution counter.
> > >
> > > What is it that you are trying to do with this time? Calculate a really
> > > accurate time-of-day? Or measure a delta between two events?
> > >
> > > Paul T.
> > >
> > > "Jim H" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > >>I need to keep the time with data that is coming into my app. On the
> > >>desktop I use DateTime.Now.Ticks to get a time stamp down to the
> > >>thousandths of a second. On the desktop is gave me numbers like this:
> > >> 632312367562450276
> > >> 632312367562606512
> > >>
> > >> On the PPC I get numbers like this:
> > >> 632314491430000000
> > >> 632314491500000000
> > >>
> > >> The precision is not there. The numbers I get from the PPC have gaps
> > >> anywhere from 2 to 5 seconds. The gaps on the desktop are approx .015
> > >> seconds. Is there a way to get a more accurate time stamp from PPC?
> > >>
> > >> Thanks,
> > >> jim
> > >>
> > >
> > >

> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programs to keep your time more accurate WhiteTea77581 Windows XP General 0 29th Jun 2009 01:49 AM
Accurate time =?Utf-8?B?S2VsbHk=?= Microsoft Windows 2000 Deployment 1 17th Apr 2005 10:33 PM
Time is not accurate =?Utf-8?B?ZW5hcmFuZW4=?= Windows XP Help 10 10th Apr 2005 03:49 AM
How to get accurate time (to 100 nano second) in C#? Andy Lee Microsoft C# .NET 6 5th Feb 2004 04:02 AM
Accurate GMT Time Server Steevo Windows XP General 6 9th Nov 2003 03:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:06 PM.