@@ -291,6 +291,22 @@ void MarkBootstrapComplete(const FunctionCallbackInfo<Value>& args) {
291
291
performance::NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE);
292
292
}
293
293
294
+ static double PerformanceNowImpl () {
295
+ return static_cast <double >(uv_hrtime () - performance_process_start) /
296
+ NANOS_PER_MILLIS;
297
+ }
298
+
299
+ static double FastPerformanceNow (v8::Local<v8::Value> receiver) {
300
+ return PerformanceNowImpl ();
301
+ }
302
+
303
+ static void SlowPerformanceNow (const FunctionCallbackInfo<Value>& args) {
304
+ args.GetReturnValue ().Set (PerformanceNowImpl ());
305
+ }
306
+
307
+ static v8::CFunction fast_performance_now (
308
+ v8::CFunction::Make (FastPerformanceNow));
309
+
294
310
static void CreatePerIsolateProperties (IsolateData* isolate_data,
295
311
Local<ObjectTemplate> target) {
296
312
Isolate* isolate = isolate_data->isolate ();
@@ -311,6 +327,8 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
311
327
SetMethod (isolate, target, " getTimeOriginTimestamp" , GetTimeOriginTimeStamp);
312
328
SetMethod (isolate, target, " createELDHistogram" , CreateELDHistogram);
313
329
SetMethod (isolate, target, " markBootstrapComplete" , MarkBootstrapComplete);
330
+ SetFastMethodNoSideEffect (
331
+ isolate, target, " now" , SlowPerformanceNow, &fast_performance_now);
314
332
}
315
333
316
334
void CreatePerContextProperties (Local<Object> target,
@@ -376,6 +394,9 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
376
394
registry->Register (GetTimeOriginTimeStamp);
377
395
registry->Register (CreateELDHistogram);
378
396
registry->Register (MarkBootstrapComplete);
397
+ registry->Register (SlowPerformanceNow);
398
+ registry->Register (FastPerformanceNow);
399
+ registry->Register (fast_performance_now.GetTypeInfo ());
379
400
HistogramBase::RegisterExternalReferences (registry);
380
401
IntervalHistogram::RegisterExternalReferences (registry);
381
402
}
0 commit comments