Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - time measurement: (4 Items)
   
time measurement  
I working on QNX 4.25 loaded in power PC SBC board with processors speed
of 1.4 Ghz.I need to measure time difference between 2 events which can
vary from 500 usec to 5000 usec. The resolution of timer should be within
1 usecond. Is there any way to do this?

with regards

yogesh r sagane


RE: time measurement  
Not sure if it'll meet your resolution requirements, but here's what I just did in a C++ program to self measure it.

#include <sys/time.h>

timeval StartTime, EndTime;
gettimeofday(&StartTime, NULL);
Output("Time Start: " + toString(StartTime));
Do Something....
gettimeofday(&EndTime, NULL);
Output("Time End: " + toString(EndTime));
	
	
double t1=StartTime.tv_sec+(StartTime.tv_usec/1000000.0);
double t2=EndTime.tv_sec+(EndTime.tv_usec/1000000.0);
Output(toString(t2-t1) +" seconds elapsed");

Output is a function that I wrote so I can send all my output to one common spot...be it stdout, a file log, or a custom
 tracing system.

- Mike Briggs

-----Original Message-----
From: yogesh sagane [mailto:community-noreply@qnx.com] 
Sent: Wednesday, August 11, 2010 2:22 AM
To: general-community
Subject: time measurement

I working on QNX 4.25 loaded in power PC SBC board with processors speed
of 1.4 Ghz.I need to measure time difference between 2 events which can
vary from 500 usec to 5000 usec. The resolution of timer should be within
1 usecond. Is there any way to do this?

with regards

yogesh r sagane






_______________________________________________

General
http://community.qnx.com/sf/go/post62593
Re: time measurement  
I don't know if it exists on qnx 4 but on neutrino there is 
ClockCycles() call that gives the most precise cpu counter on x86 is 
less than a nanosecond. So you do something like this

uint64_t cycles_per_second = (SYSPAGE_ENTRY(qtime)->cycles_per_sec);
...
uint64_t time = ClockCycles();
// do stuff
time = ClockCycles() - time;
double seconds = time / (double) cycles_per_second;




On 11/08/10 02:21 AM, yogesh sagane wrote:
> I working on QNX 4.25 loaded in power PC SBC board with processors speed
> of 1.4 Ghz.I need to measure time difference between 2 events which can
> vary from 500 usec to 5000 usec. The resolution of timer should be within
> 1 usecond. Is there any way to do this?
>
> with regards
>
> yogesh r sagane
>
>
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post62593
>
RE: time measurement  
I use the following:

void 			rdtsc64( int64_t *ptr );
#pragma aux rdtsc64 = "db 0fh,31h" "mov [ebx],eax" "mov [ebx+4],edx" \
	parm nomemory [ebx] modify exact nomemory [eax edx];		

Int64_t is a typedef that  look like

 struct {
	signed low;
	signed high;
};

A call to rdtsc64 will give you the number of cpu cycles ran since last reboot.

To get the value in seconds:

return ((double)(value.high) * ULONG_MAX + value.low) / freq;

freq is the frequency in hz of the cpu clock. 

-----Message d'origine-----
De : yogesh sagane [mailto:community-noreply@qnx.com] 
Envoyé : 11 août 2010 02:22
À : general-community
Objet : time measurement

I working on QNX 4.25 loaded in power PC SBC board with processors speed of 1.4 Ghz.I need to measure time difference 
between 2 events which can vary from 500 usec to 5000 usec. The resolution of timer should be within
1 usecond. Is there any way to do this?

with regards

yogesh r sagane






_______________________________________________

General
http://community.qnx.com/sf/go/post62593