From 8d61e6c2495d226400f4fe250990d7eae855fee5 Mon Sep 17 00:00:00 2001 From: Jianghua Yang Date: Thu, 27 Aug 2015 15:49:13 +0800 Subject: [PATCH] process: improve implement of process.uptime() --- src/node.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index 084fe900cd35d4..49da1bef446400 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1949,10 +1949,10 @@ static void Uptime(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); double uptime; - uv_update_time(env->event_loop()); - uptime = uv_now(env->event_loop()) - prog_start_time; + uv_uptime(&uptime); + uptime -= prog_start_time; - args.GetReturnValue().Set(Number::New(env->isolate(), uptime / 1000)); + args.GetReturnValue().Set(Number::New(env->isolate(), uptime)); } @@ -3620,7 +3620,7 @@ void Init(int* argc, int* exec_argc, const char*** exec_argv) { // Initialize prog_start_time to get relative uptime. - prog_start_time = static_cast(uv_now(uv_default_loop())); + uv_uptime(&prog_start_time); // Make inherited handles noninheritable. uv_disable_stdio_inheritance();