@@ -17,6 +17,7 @@ namespace performance {
17
17
using v8::Array;
18
18
using v8::Context;
19
19
using v8::DontDelete;
20
+ using v8::FastApiCallbackOptions;
20
21
using v8::Function;
21
22
using v8::FunctionCallbackInfo;
22
23
using v8::GCCallbackFlags;
@@ -263,6 +264,15 @@ void LoopIdleTime(const FunctionCallbackInfo<Value>& args) {
263
264
args.GetReturnValue ().Set (1.0 * idle_time / NANOS_PER_MILLIS);
264
265
}
265
266
267
+ static double FastLoopIdleTime (v8::Local<v8::Value> receiver,
268
+ FastApiCallbackOptions& options) { // NOLINT(runtime/references)
269
+ Environment* env = Environment::GetCurrent (options.isolate );
270
+ uint64_t idle_time = uv_metrics_idle_time (env->event_loop ());
271
+ return 1.0 * idle_time / NANOS_PER_MILLIS;
272
+ }
273
+
274
+ static v8::CFunction fast_loop_idle_time (v8::CFunction::Make(FastLoopIdleTime));
275
+
266
276
void UvMetricsInfo (const FunctionCallbackInfo<Value>& args) {
267
277
Environment* env = Environment::GetCurrent (args);
268
278
Isolate* isolate = env->isolate ();
@@ -338,7 +348,8 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
338
348
" removeGarbageCollectionTracking" ,
339
349
RemoveGarbageCollectionTracking);
340
350
SetMethod (isolate, target, " notify" , Notify);
341
- SetMethod (isolate, target, " loopIdleTime" , LoopIdleTime);
351
+ SetFastMethodNoSideEffect (
352
+ isolate, target, " loopIdleTime" , LoopIdleTime, &fast_loop_idle_time);
342
353
SetMethod (isolate, target, " createELDHistogram" , CreateELDHistogram);
343
354
SetMethod (isolate, target, " markBootstrapComplete" , MarkBootstrapComplete);
344
355
SetMethod (isolate, target, " uvMetricsInfo" , UvMetricsInfo);
@@ -406,6 +417,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
406
417
registry->Register (RemoveGarbageCollectionTracking);
407
418
registry->Register (Notify);
408
419
registry->Register (LoopIdleTime);
420
+ registry->Register (FastLoopIdleTime);
421
+ registry->Register (fast_loop_idle_time.GetTypeInfo ());
409
422
registry->Register (CreateELDHistogram);
410
423
registry->Register (MarkBootstrapComplete);
411
424
registry->Register (UvMetricsInfo);
0 commit comments