summaryrefslogtreecommitdiff
path: root/src/node_process_methods.cc
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-02-09 23:48:14 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-02-18 17:58:22 +0800
commitfd0a861cdb3088f60ee56a8adef05fd50b71f817 (patch)
treeb99a8fd488e5e6da3c2aaf592a98a7120dbb1292 /src/node_process_methods.cc
parent2ae45d3b17f9c51fccffc4041e195e04b4b18c15 (diff)
downloadandroid-node-v8-fd0a861cdb3088f60ee56a8adef05fd50b71f817.tar.gz
android-node-v8-fd0a861cdb3088f60ee56a8adef05fd50b71f817.tar.bz2
android-node-v8-fd0a861cdb3088f60ee56a8adef05fd50b71f817.zip
src: unify uptime base used across the code base
This patch joins `per_process::prog_start_time` (a double) and `performance::performance_node_start` (a uint64_t) into a `per_process::node_start_time` (a uint64_t) which gets initialized in `node::Start()`. PR-URL: https://github.com/nodejs/node/pull/26016 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_process_methods.cc')
-rw-r--r--src/node_process_methods.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/node_process_methods.cc b/src/node_process_methods.cc
index be91a11f56..dfcc6641a1 100644
--- a/src/node_process_methods.cc
+++ b/src/node_process_methods.cc
@@ -44,6 +44,7 @@ using v8::Isolate;
using v8::Local;
using v8::Name;
using v8::NewStringType;
+using v8::Number;
using v8::Object;
using v8::String;
using v8::Uint32;
@@ -58,6 +59,8 @@ Mutex umask_mutex;
#define MICROS_PER_SEC 1e6
// used in Hrtime() 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. */
@@ -239,12 +242,12 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
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()) - per_process::prog_start_time;
-
- args.GetReturnValue().Set(uptime / 1000);
+ double uptime =
+ static_cast<double>(uv_hrtime() - per_process::node_start_time);
+ Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_MICROS);
+ args.GetReturnValue().Set(result);
}
static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) {