@@ -154,6 +154,9 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
154154 v8Initialized_ = true ;
155155 }
156156
157+ startTime = platform_->MonotonicallyIncreasingTime ();
158+ realtimeOrigin = platform_->CurrentClockTimeMillis ();
159+
157160 // auto version = v8::V8::GetVersion();
158161
159162 Isolate::CreateParams create_params;
@@ -389,16 +392,17 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
389392 Local<FunctionTemplate> nowFuncTemplate = FunctionTemplate::New (isolate, PerformanceNowCallback);
390393 performanceTemplate->Set (tns::ToV8String (isolate, " now" ), nowFuncTemplate);
391394
395+ performanceTemplate->Set (tns::ToV8String (isolate, " timeOrigin" ),
396+ v8::Number::New (isolate, realtimeOrigin));
397+
392398 Local<v8::String> performancePropertyName = ToV8String (isolate, " performance" );
393399 globalTemplate->Set (performancePropertyName, performanceTemplate);
394400}
395401
396402void Runtime::PerformanceNowCallback (const FunctionCallbackInfo<Value>& args) {
397- std::chrono::system_clock::time_point now = std::chrono::system_clock::now ();
398- std::chrono::milliseconds timestampMs =
399- std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch ());
400- double result = timestampMs.count ();
401- args.GetReturnValue ().Set (result);
403+ auto runtime = Runtime::GetRuntime (args.GetIsolate ());
404+ args.GetReturnValue ().Set (
405+ (runtime->platform_ ->MonotonicallyIncreasingTime () - runtime->startTime ) * 1000.0 );
402406}
403407
404408void Runtime::DefineNativeScriptVersion (Isolate* isolate, Local<ObjectTemplate> globalTemplate) {
0 commit comments