Showing posts with label time nanosecond Linux. Show all posts
Showing posts with label time nanosecond Linux. Show all posts

Mar 15, 2011

Use time function to get timestamp in nanoseconds on Linux


#include < time.h >

#include < stdio.h >

int GetTime()
{

   struct timespec tsp;

   clock_gettime(CLOCK_REALTIME, &tsp);   //Call clock_gettime to fill tsp

   fprintf(stdout, "time=%d.%d\n", tsp.tv_sec, tsp.tv_nsec);

   fflush(stdout);

}