2013/7/26 KOSAKI Motohiro <kosaki.motohiro / gmail.com>:

> Really? I don't think so because CLOCK_*_CPUTIME_ID have less precious than
> CLOCK_REALTIME. following "t" often show 0 on several OSs.
>
>
> t0 = clock_gettime(CLOCK_THREAD_CPUTIME_ID)
> # blah blah blah
> t1 = clock_gettime(CLOCK_THREAD_CPUTIME_ID)
> t = t1 - t0

At least, my system can return 1ns unit.
(It doesn't mean 1ns accuracy, of course.)

In following result, 4666 and 4667 are returned.

% ./ruby -ve '
t1 = Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :nanoseconds)
while true
  t2 = Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :nanoseconds)
  p t2-t1
  t1 = t2
end
'|head -20|sort -n
ruby 2.1.0dev (2013-07-19 trunk 42049) [x86_64-linux]
2861
3984
4154
4189
4222
4267
4452
4567
4620
4666
4667
4771
4870
4920
5296
6155
6428
12690
20290
-e:5:in `p': Broken pipe (Errno::EPIPE)
	from -e:5:in `<main>'
% uname -mrsv
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1 x86_64

Other platforms can behave differently, though.
-- 
Tanaka Akira