summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-03-26 17:09:27 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-06-06 15:04:38 -0700
commit654267609b54e9943eb102989159ffd002cc618a (patch)
treeb842cd75c1edd5216552839fe3a05db442af6dbb
parentb93a51e3a61be44db3e566d3b4bf8b6d2c28db6f (diff)
downloadnode-654267609b54e9943eb102989159ffd002cc618a.tar.gz
src: avoid extra syscalls during node init
-rw-r--r--src/node.cc12
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();