summaryrefslogtreecommitdiff
path: root/src/node_process_methods.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-02-20 01:40:40 +0800
committerRich Trott <rtrott@gmail.com>2019-02-19 13:29:26 -0800
commita32c57453674617f454035fe206d8e93ec4aef33 (patch)
treee0f2f1e3976d93bc601ec78ff190b6c1c4b6e285 /src/node_process_methods.cc
parent129516dfa2907739b07a0579eb4fd3665938c1a4 (diff)
downloadandroid-node-v8-a32c57453674617f454035fe206d8e93ec4aef33.tar.gz
android-node-v8-a32c57453674617f454035fe206d8e93ec4aef33.tar.bz2
android-node-v8-a32c57453674617f454035fe206d8e93ec4aef33.zip
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 <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/node_process_methods.cc')
-rw-r--r--src/node_process_methods.cc6
1 files changed, 2 insertions, 4 deletions
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<Value>& args) {
uv_update_time(env->event_loop());
double uptime =
static_cast<double>(uv_hrtime() - per_process::node_start_time);
- Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_MICROS);
+ Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_SEC);
args.GetReturnValue().Set(result);
}