Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: improve implement of process.uptime() #2572

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1949,10 +1949,10 @@ static void Uptime(const FunctionCallbackInfo<Value>& 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));
}


Expand Down Expand Up @@ -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<double>(uv_now(uv_default_loop()));
uv_uptime(&prog_start_time);

// Make inherited handles noninheritable.
uv_disable_stdio_inheritance();
Expand Down