diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-03-26 17:09:27 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-06-06 15:04:38 -0700 |
commit | 654267609b54e9943eb102989159ffd002cc618a (patch) | |
tree | b842cd75c1edd5216552839fe3a05db442af6dbb | |
parent | b93a51e3a61be44db3e566d3b4bf8b6d2c28db6f (diff) | |
download | node-654267609b54e9943eb102989159ffd002cc618a.tar.gz |
src: avoid extra syscalls during node init
-rw-r--r-- | src/node.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/node.cc b/src/node.cc index 3d4008e5a..e9a0d1220 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1614,15 +1614,11 @@ static void CheckStatus(uv_timer_t* watcher, int status) { static Handle<Value> Uptime(const Arguments& args) { HandleScope scope; - double uptime; - uv_err_t err = uv_uptime(&uptime); + uv_update_time(uv_default_loop()); + double delta = (uv_now(uv_default_loop()) - prog_start_time) / 1000; - if (err.code != UV_OK) { - return Undefined(); - } - - return scope.Close(Number::New(uptime - prog_start_time)); + return scope.Close(Number::New(static_cast<int64_t>(delta))); } @@ -2772,7 +2768,7 @@ static Handle<Value> DebugEnd(const Arguments& args) { char** Init(int argc, char *argv[]) { // Initialize prog_start_time to get relative uptime. - uv_uptime(&prog_start_time); + prog_start_time = uv_now(uv_default_loop()); // Make inherited handles noninheritable. uv_disable_stdio_inheritance(); |