Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fde4011

Browse filesBrowse files
joyeecheungrvagg
authored andcommitted
process: fix calculation in process.uptime()
In #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: #26016 PR-URL: #26206 Fixes: #26205 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 6b7d836 commit fde4011
Copy full SHA for fde4011

File tree

Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Open diff view settings
Collapse file

‎src/node_process_methods.cc‎

Copy file name to clipboardExpand all lines: src/node_process_methods.cc
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ Mutex umask_mutex;
5757

5858
// Microseconds in a second, as a float, used in CPUUsage() below
5959
#define MICROS_PER_SEC 1e6
60-
// used in Hrtime() below
60+
// used in Hrtime() and Uptime() below
6161
#define NANOS_PER_SEC 1000000000
62-
// Used in Uptime()
63-
#define NANOS_PER_MICROS 1e3
6462

6563
#ifdef _WIN32
6664
/* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */
@@ -246,7 +244,7 @@ static void Uptime(const FunctionCallbackInfo<Value>& args) {
246244
uv_update_time(env->event_loop());
247245
double uptime =
248246
static_cast<double>(uv_hrtime() - per_process::node_start_time);
249-
Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_MICROS);
247+
Local<Number> result = Number::New(env->isolate(), uptime / NANOS_PER_SEC);
250248
args.GetReturnValue().Set(result);
251249
}
252250

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.