From: Tanaka Akira Date: 2013-08-23T07:37:48+09:00 Subject: [ruby-core:56786] Re: [ruby-trunk - Feature #8809][Open] Process.clock_getres 2013/8/23 David MacMahon : >> >> Process.clock_getres(Process::CLOCK_MONOTONIC) #=> 1.0e-09 >> Process.clock_getres(Process::CLOCK_MONOTONIC_COARSE) #=> 0.00400025 >> >> The result means that the resolution of CLOCK_MONOTONIC is 1ns and >> the resolution of CLOCK_MONOTONIC_COARSE is 4.00025ms. > > Did you consider having these methods return Rational rather than Float? Process.clock_getres can return rational if it supports :rational_second as a unit. The current default of unit is :float_second and I think float is good enough. >> Process.clock_getres(:SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) #=> 1000000.0 > > How would you feel about supporting :ns and :hz as equivalents for :nanosecond and :hertz? It is difficult to support :microsecond in that style because the SI prefix, Greek m, is not representable in ASCII. Someone may argue :hz should be :Hz. I feel :float_s is bit curious. So it is difficult to adopt :ns style as canonical style of unit. I think several aliases are possible but I'd like to concentrate to main feature. The discussion for what aliases should be added or not can be diverge. >> Note that >> Process.clock_getres(:POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) is the clock ticks per second (CLK_TCK) and >> Process.clock_getres(:ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID, :hertz) is CLOCK_PER_SEC. >> I wanted to access them easily to investigate emulated clock behaviors on >> various OSes. > > Those are some long symbols! Are these intended only for experimental/investigative use? I choose the long symbols that is longer than Process::CLOCK_PROCESS_CPUTIME_ID. Basically users should use Process::CLOCK_PROCESS_CPUTIME_ID if no reason. -- Tanaka Akira