it's about time

I want to know how much time a call took in a unit more granular than
seconds. (nano, milli)

example:

x = gettime();
printf(“this takes how long?\n”);
y = gettime();
printf(“this took <%u> long?\n”, y-x);

Thanks

If you have a pentium or higher, you could use the rdtsc instruction to get
the cycle count before and after.

Or go about the measurement a different way - execute the call in a loop,
over the period of a second. Divide out the number of iterations and you
have your avg. execution time.

-Adam

Doug Rixmann <rixmannd@rdsdata.com> wrote in message
news:b4no3b$b4t$1@inn.qnx.com

I want to know how much time a call took in a unit more granular than
seconds. (nano, milli)

example:

x = gettime();
printf(“this takes how long?\n”);
y = gettime();
printf(“this took <%u> long?\n”, y-x);

Thanks

Doug Rixmann <> rixmannd@rdsdata.com> > wrote in message
news:b4no3b$b4t$> 1@inn.qnx.com> …
I want to know how much time a call took in a unit more granular than
seconds. (nano, milli)

example:

x = gettime();
printf(“this takes how long?\n”);
y = gettime();
printf(“this took <%u> long?\n”, y-x);

Thanks

Look at clock_gettime().


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

Bill Caroselli <qtps@earthlink.net> wrote:

Doug Rixmann <> rixmannd@rdsdata.com> > wrote in message
news:b4no3b$b4t$> 1@inn.qnx.com> …
I want to know how much time a call took in a unit more granular than
seconds. (nano, milli)

example:

x = gettime();
printf(“this takes how long?\n”);
y = gettime();
printf(“this took <%u> long?\n”, y-x);

Thanks


Look at clock_gettime().

Still won’t be granular enough for a single function call (usually).

Try:

ftp.qnx.com:/usr/free/qnx4/os/utils/examples/Micro_time.tgz

Which has sample code for getting the Pentium free-running counter
(rdtsc) and maybe some other useful stuff.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.