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.


  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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: