@@ -117,22 +117,32 @@ def self.time
117
117
118
118
def self . clock_getres ( id , unit = :float_second )
119
119
res = case id
120
+ when :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ,
121
+ CLOCK_MONOTONIC
122
+ 1
120
123
when :GETTIMEOFDAY_BASED_CLOCK_REALTIME ,
121
124
:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID ,
122
125
:CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID
123
126
1_000
127
+ when CLOCK_REALTIME
128
+ 1_000_000
129
+ when :TIMES_BASED_CLOCK_MONOTONIC ,
130
+ :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID
131
+ 10_000_000
124
132
when :TIME_BASED_CLOCK_REALTIME
125
133
1_000_000_000
126
- when :MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ,
127
- :TIMES_BASED_CLOCK_MONOTONIC
128
- 1
129
- when :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID
134
+ when Symbol
135
+ raise Errno ::EINVAL
130
136
else
131
- res = Truffle ::POSIX . truffleposix_clock_getres ( id )
132
- Errno . handle if res == 0
137
+ _res = Truffle ::POSIX . truffleposix_clock_getres ( id )
138
+ if _res == 0 then
139
+ Errno . handle
140
+ else
141
+ _res
142
+ end
133
143
end
134
144
135
- if unit == :hertz then
145
+ if :hertz == unit then
136
146
1.0 / nanoseconds_to_unit ( res , :float_second )
137
147
else
138
148
nanoseconds_to_unit ( res , unit )
@@ -171,7 +181,7 @@ def self.normalize_clock_id(id)
171
181
end
172
182
end
173
183
174
- def self . nanoseconds_to_unit ( nanoseconds , unit = :nanosecond )
184
+ def self . nanoseconds_to_unit ( nanoseconds , unit )
175
185
case unit
176
186
when :nanosecond
177
187
nanoseconds
0 commit comments