@@ -154,6 +154,9 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
154
154
v8Initialized_ = true ;
155
155
}
156
156
157
+ startTime = platform_->MonotonicallyIncreasingTime ();
158
+ realtimeOrigin = platform_->CurrentClockTimeMillis ();
159
+
157
160
// auto version = v8::V8::GetVersion();
158
161
159
162
Isolate::CreateParams create_params;
@@ -389,16 +392,17 @@ void DisposeIsolateWhenPossible(Isolate* isolate) {
389
392
Local<FunctionTemplate> nowFuncTemplate = FunctionTemplate::New (isolate, PerformanceNowCallback);
390
393
performanceTemplate->Set (tns::ToV8String (isolate, " now" ), nowFuncTemplate);
391
394
395
+ performanceTemplate->Set (tns::ToV8String (isolate, " timeOrigin" ),
396
+ v8::Number::New (isolate, realtimeOrigin));
397
+
392
398
Local<v8::String> performancePropertyName = ToV8String (isolate, " performance" );
393
399
globalTemplate->Set (performancePropertyName, performanceTemplate);
394
400
}
395
401
396
402
void 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 );
402
406
}
403
407
404
408
void Runtime::DefineNativeScriptVersion (Isolate* isolate, Local<ObjectTemplate> globalTemplate) {
0 commit comments