@@ -182,34 +182,35 @@ public double time() {
182
182
return timeSeconds ();
183
183
}
184
184
}
185
-
185
+
186
186
// time.time_ns()
187
- @ Builtin (name = "time_ns" , minNumOfPositionalArgs = 0 ,
188
- doc = "Similar to time() but returns time as an integer number of nanoseconds since the epoch." )
187
+ @ Builtin (name = "time_ns" , minNumOfPositionalArgs = 0 , doc = "Similar to time() but returns time as an integer number of nanoseconds since the epoch." )
189
188
@ GenerateNodeFactory
190
189
public abstract static class PythonTimeNsNode extends PythonBuiltinNode {
191
190
192
191
/**
193
- * The maximum date, which are systems able to handle is 2262 04 11. This
194
- * corresponds to the 64 bit long.
195
- * @return
192
+ * The maximum date, which are systems able to handle is 2262 04 11. This corresponds to the
193
+ * 64 bit long.
194
+ *
195
+ * @return
196
196
*/
197
197
@ Specialization
198
198
public long time () {
199
199
return timeNanoSeconds ();
200
200
}
201
-
201
+
202
202
@ TruffleBoundary
203
203
private static long timeNanoSeconds () {
204
204
Instant now = Instant .now ();
205
- // From java we are not able to obtain the nano seconds resolution. It depends on the jdk
205
+ // From java we are not able to obtain the nano seconds resolution. It depends on the
206
+ // jdk
206
207
// JKD 1.8 the resolution is usually miliseconds (for example 1576081173486000000)
207
- // From JDK 9 including JDK 11 the resolution is usually microseconds (for example 1576082578022393000)
208
+ // From JDK 9 including JDK 11 the resolution is usually microseconds (for example
209
+ // 1576082578022393000)
208
210
// To obtain really nanosecond resulution we have to fake the nanoseconds
209
211
return now .getEpochSecond () * 1000000000L + now .getNano ();
210
212
}
211
213
}
212
-
213
214
214
215
// time.monotonic()
215
216
@ Builtin (name = "monotonic" , minNumOfPositionalArgs = 0 )
@@ -222,7 +223,7 @@ public double time() {
222
223
return System .nanoTime () / 1000000000D ;
223
224
}
224
225
}
225
-
226
+
226
227
// time.monotonic_ns()
227
228
@ Builtin (name = "monotonic_ns" , minNumOfPositionalArgs = 0 , doc = "Similar to monotonic(), but return time as nanoseconds." )
228
229
@ GenerateNodeFactory
@@ -244,11 +245,11 @@ public double counter() {
244
245
return (System .nanoTime () - PERF_COUNTER_START ) / 1000_000_000.0 ;
245
246
}
246
247
}
247
-
248
+
248
249
@ Builtin (name = "perf_counter_ns" , minNumOfPositionalArgs = 0 )
249
250
@ GenerateNodeFactory
250
251
public abstract static class PythonPerfCounterNsNode extends PythonBuiltinNode {
251
-
252
+
252
253
@ Specialization
253
254
@ TruffleBoundary
254
255
public long counter () {
0 commit comments