![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Linux Going Big Time and Prime Time Against Windows, UNIX (WSJ) (Addict 3D) | iBot | UNIX and Linux RSS News | 0 | 06-21-2007 01:10 PM |
| Start time/end time and status of crontab job | thambi | Shell Programming and Scripting | 3 | 05-16-2007 07:24 AM |
| How To Provide Time Sync Using Nts-150 Time Server On Unix Network? | pesty | UNIX for Advanced & Expert Users | 2 | 03-21-2007 11:20 PM |
| Losing Time/Time cloclk | azdauk | UNIX for Dummies Questions & Answers | 4 | 11-06-2003 06:33 AM |
| default time in Solaris 8 for time-wait | eloquent99 | UNIX for Dummies Questions & Answers | 1 | 04-01-2003 06:45 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#8
|
|||
|
|||
|
my brain is not working today. alas another monday couldnt go any faster.
do you know how i can get it to display 10th and 100ths of a second also? |
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
Change
tm->tm_sec, tv.tv_usec); to be tm->sec, tv.tv_usec/100000); or tm->sec, tv.tv_usec/10000); |
|
#10
|
|||
|
|||
|
and even a basterd like myself must bow down to the awsome powers of Perderabo
|
|
#11
|
|||
|
|||
|
well folks the following code is just a complete listing of the code Perderabo wrote.
This will print out the 10ths 100ths microseconds (1,000,0000th) of a second. IE: $./a.out 9 99 999999 Code:
#include <stdlib.h>
#include <sys/time.h>
main()
{
struct timeval tv;
struct timezone tz;
struct tm *tm;
gettimeofday(&tv, &tz);
tm=localtime(&tv.tv_sec);
printf("%d %d %d \n", tv.tv_usec/100000, tv.tv_usec/10000, tv.tv_usec);
exit(0);
}
Code:
/* I added this to make the microseconds program work needed to define TM */ #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> +#if !defined(TM_IN_SYS_TIME) +#include <time.h> +#endif #else #include <time.h> #endif /* ENTER YOUR NAME HERE added this on ENTER THE CURRENT DATE HERE */ |
|
#12
|
||||
|
||||
|
Quote:
__________________
Not quite as cool as all the other Kids... |
|
#13
|
|||
|
|||
|
I don't understand. I need to measure how long it takes something to run in microseconds. Like this:
start RUN CODE end display number of microseconds that it took to "RUN CODE" Please help. |
|
#14
|
||||
|
||||
|
Call gettimeofday() before and after the sequence in question. Then subtract the "before" value from the "after" value to get elapsed time. The only tricky part is that there are two integers (seconds and microseconds) to specify the time of day. So might need to "borrow" just like subtracting month and day to get days.
|
||||
| Google The UNIX and Linux Forums |