File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed
java/org/truffleruby/core Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ public abstract class ProcessNodes {
27
27
@ Primitive (name = "process_time_nanotime" )
28
28
public abstract static class ProcessTimeNanoTimeNode extends PrimitiveArrayArgumentsNode {
29
29
30
- @ TruffleBoundary
31
30
@ Specialization
32
31
protected long nanoTime () {
33
32
return System .nanoTime ();
Original file line number Diff line number Diff line change @@ -156,10 +156,10 @@ def self.clock_gettime(id, unit=:float_second)
156
156
end
157
157
158
158
case id
159
+ when CLOCK_MONOTONIC # most common clock id
160
+ time = Primitive . process_time_nanotime
159
161
when CLOCK_REALTIME
160
162
time = Primitive . process_time_instant
161
- when CLOCK_MONOTONIC
162
- time = Primitive . process_time_nanotime
163
163
else
164
164
time = Truffle ::POSIX . truffleposix_clock_gettime ( id )
165
165
Errno . handle if time == 0
@@ -169,21 +169,21 @@ def self.clock_gettime(id, unit=:float_second)
169
169
end
170
170
171
171
def self . nanoseconds_to_unit ( nanoseconds , unit )
172
- case unit
172
+ case unit # ordered by expected frequency
173
+ when :float_second , nil
174
+ nanoseconds / 1e9
173
175
when :nanosecond
174
176
nanoseconds
175
177
when :microsecond
176
178
nanoseconds / 1_000
177
- when :millisecond
178
- nanoseconds / 1_000_000
179
- when :second
180
- nanoseconds / 1_000_000_000
181
179
when :float_microsecond
182
180
nanoseconds / 1e3
183
181
when :float_millisecond
184
182
nanoseconds / 1e6
185
- when :float_second , nil
186
- nanoseconds / 1e9
183
+ when :second
184
+ nanoseconds / 1_000_000_000
185
+ when :millisecond
186
+ nanoseconds / 1_000_000
187
187
else
188
188
raise ArgumentError , "unexpected unit: #{ unit } "
189
189
end
You can’t perform that action at this time.
0 commit comments