On Aug 22, 2013, at 7:33 AM, akr (Akira Tanaka) wrote:

> I made a pacth to invoke clock_getres function.

Thanks for making a patch!  It makes the discussion much less abstract =
(more real?).  I think I will try to follow your example in the future.

>=20
>  Process.clock_getres(Process::CLOCK_MONOTONIC) #=3D> 1.0e-09
>  Process.clock_getres(Process::CLOCK_MONOTONIC_COARSE) #=3D> =
0.00400025
>=20
> 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?

>=20
> Process.clock_getres has optional unit argument as =
Process.clock_gettime.
>=20
>  Process.clock_getres(Process::CLOCK_MONOTONIC, :nanosecond) #=3D> 1
>  Process.clock_getres(Process::CLOCK_MONOTONIC_COARSE, :nanosecond) =
#=3D> 4000250
>=20
> It supports emulated clocks as well.
>=20
>  Process.clock_getres(:SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME) #=3D> =
1.0000000000000002e-06
>  Process.clock_getres(:SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) =
#=3D> 1.0000000000000002e-06
>=20
> The unit argument can be :hertz, which means the reciprocal of the =
second.
>=20
>  Process.clock_getres(:SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID, =
:hertz) #=3D> 1000000.0

How would you feel about supporting :ns and :hz as equivalents for =
:nanosecond and :hertz?

> 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?

> Any comments?

I appreciate having access to POSIX functionality, so I'm all for this =
idea!

Thanks,
Dave