G
George Orwell
daffyduck said:is possible to get in seconds with a precision of 0.0000 the time get
by one function ?
i check clock() but im getting 0 with this:
1 #include <stdio.h>
2 #include <time.h>
3
4 int
5 main(){
6 float time1, time2;
7 int a;
8 time1 = clock();
9 for(a=0;a<100; a++){
10 printf("a");
11 }
12 time2 = clock();
13 printf("seconds: %f\n",((float)tempo2 - (float)tempo1) /
CLOCKS_PER_SEC);
14 }
Hi, buddy. How you doing?
That's because the division by CLOCKS_PER_SEC, by definition,
is calculating the number of seconds elapsed between the two
points.
The C standard doesn't specify a particular resolution, and you
can't even examine the value of CLOCKS_PER_SEC to determine the
particular resolution used.
In fact, you're not even guaranteed a return value from clock(),
which could return (clock_t)(-1) if the processor time isn't
available.
You have some options available.
1. You can use a profiling tool if you have one available. For
example, gcc has a -pg compilation option that produces an output
file for gprof, the GNU profiler. I believe the resolution for
that is still pretty limited, though.
2. You can tell us what platform you're on, and some people here
would be more than happy to indicate a platform-specific system
call for your system. If you choose this option, you may want
to cross-post to a platform-specific newsgroup as well as
comp.lang.c, otherwise you'll get a lot of troll replies.
I hope this has been of some help to you. Have a good
night.
Yours,
Han from China
Il mittente di questo messaggio|The sender address of this
non corrisponde ad un utente |message is not related to a real
reale ma all'indirizzo fittizio|person but to a fake address of an
di un sistema anonimizzatore |anonymous system
Per maggiori informazioni |For more info
https://www.mixmaster.it