Wednesday, February 29, 2012

Real-Time measurement in C

For those of you, who could not find it somewhere else.
Here is the code snippet to get time measurements exact to  the microsecond on a Linux system with pure C.
Fun fact, the struct is already there, should be defined in time.h
rt_printk is real-time printf to read your output use command dmesg
int main(void)
 char buffer[30];
 struct timeval tv;
 time_t curtime;
 gettimeofday(&tv, NULL);
 strftime(buffer,30,"%m-%d-%Y  %T.",localtime(&curtime));
 return 0;

No comments:

Post a Comment