@@ -291,6 +291,22 @@ void MarkBootstrapComplete(const FunctionCallbackInfo<Value>& args) {
291291 performance::NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE);
292292}
293293
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+
294310static void CreatePerIsolateProperties (IsolateData* isolate_data,
295311 Local<ObjectTemplate> target) {
296312 Isolate* isolate = isolate_data->isolate ();
@@ -311,6 +327,8 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
311327 SetMethod (isolate, target, " getTimeOriginTimestamp" , GetTimeOriginTimeStamp);
312328 SetMethod (isolate, target, " createELDHistogram" , CreateELDHistogram);
313329 SetMethod (isolate, target, " markBootstrapComplete" , MarkBootstrapComplete);
330+ SetFastMethodNoSideEffect (
331+ isolate, target, " now" , SlowPerformanceNow, &fast_performance_now);
314332}
315333
316334void CreatePerContextProperties (Local<Object> target,
@@ -376,6 +394,9 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
376394 registry->Register (GetTimeOriginTimeStamp);
377395 registry->Register (CreateELDHistogram);
378396 registry->Register (MarkBootstrapComplete);
397+ registry->Register (SlowPerformanceNow);
398+ registry->Register (FastPerformanceNow);
399+ registry->Register (fast_performance_now.GetTypeInfo ());
379400 HistogramBase::RegisterExternalReferences (registry);
380401 IntervalHistogram::RegisterExternalReferences (registry);
381402}
0 commit comments