據man 2 stat
說明部分:
Since kernel 2.5.48, the stat structure supports nanosecond resolution for the three file timestamp fields. Glibc
exposes the nanosecond component of each field using names of the form st_atim.tv_nsec if the _BSD_SOURCE or _SVID_SOURCE
feature test macro is defined. These fields are specified in POSIX.1-2008, and, starting with version 2.12, glibc also
exposes these field names if _POSIX_C_SOURCE is defined with the value 200809L or greater, or _XOPEN_SOURCE is defined
with the value 700 or greater. If none of the aforementioned macros are defined, then the nanosecond values are exposed
with names of the form st_atimensec. On file systems that do not support subsecond timestamps, the nanosecond fields are
returned with the value 0.
有一點要記住,即使是在納秒級的分辨率是,你可能在你的硬件沒有get精確到納秒。例如,我認爲典型的英特爾硬件只能精確到1毫秒左右,所以即使你在幾納秒內得到一個值,你通常也不能相信低於1毫秒。 – jia103