Posted by: sureshamrita | August 19, 2010

Current time in nano seconds


struct timespec tm;
clock_gettime( CLOCK_REALTIME, &tm);
cout << tm.tv_nsec;

Include <ctime> and link with -lrt option in linux. Most probably this code does not work on Windows.



Responses

  1. […] in nanoseconds which is used as a seed. For an implementation of  currentTimeNS() function see this link. Advertisement GA_googleAddAttr("AdOpt", "0"); GA_googleAddAttr("Origin", "other"); […]


Leave a comment

Categories