From a32c57453674617f454035fe206d8e93ec4aef33 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 20 Feb 2019 01:40:40 +0800 Subject: process: fix calculation in process.uptime() In https://github.com/nodejs/node/pull/26016 the result returned by process.uptime() was mistakenly set to be based in the wrong unit. This patch fixes the calculation and makes sure the returned value is in seconds. Refs: https://github.com/nodejs/node/pull/26016 PR-URL: https://github.com/nodejs/node/pull/26206 Fixes: https://github.com/nodejs/node/issues/26205 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Richard Lau --- src/node_process_methods.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/node_process_methods.cc') diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc index dfcc6641a1..80027c26eb 100644 --- a/src/node_process_methods.cc +++ b/src/node_process_methods.cc @@ -57,10 +57,8 @@ Mutex umask_mutex; // Microseconds in a second, as a float, used in CPUUsage() below #define MICROS_PER_SEC 1e6 -// used in Hrtime() below +// used in Hrtime() and Uptime() below #define NANOS_PER_SEC 1000000000 -// Used in Uptime() -#define NANOS_PER_MICROS 1e3 #ifdef _WIN32 /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ @@ -246,7 +244,7 @@ static void Uptime(const FunctionCallbackInfo& args) { uv_update_time(env->event_loop()); double uptime = static_cast(uv_hrtime() - per_process::node_start_time); - Local result = Number::New(env->isolate(), uptime / NANOS_PER_MICROS); + Local result = Number::New(env->isolate(), uptime / NANOS_PER_SEC); args.GetReturnValue().Set(result); } -- cgit v1.2.3