-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(unstable): Add "Deno.osUptime()" API #17179
Conversation
Implementation wise - looks good. However when adding new APIs to Deno namespace, we also start with making them unstable (requiring
Seems it's not needed - |
cli/tsc/dts/lib.deno.ns.d.ts
Outdated
* @tags allow-sys | ||
* @category Runtime Environment | ||
*/ | ||
export function uptime(): number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little bike-shedding maybe it should be Deno.osUptime()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deno.osUptime()
is more clear and falls in line with the naming convention of Deno.osRelease()
. I definitely prefer it over Deno.uptime()
.
I would also like to bikeshed another alternative being Deno.systemUptime()
(which is in line with Deno.systemMemoryInfo()
. I don't have strong feelings either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After checking few other places, I decided to go with osUptime
, as:
the uptime is a kernel internal value, which ticks up every cycle, it starts counting when the kernel has initialized. That is, when the first cycle has ended. Even before anything is mounted, directly after the bootloader gives control to the kernel image.
which means that IMO it should be treated as Operating System
info, where System
info should be more "hardware-like" related, as in mem/cpu/peripherals etc.
LGTM, nice work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work @kamilogorek, cleanly done!
This PR adds support for `Deno.osUptime` which reports number of seconds since os was booted. It will allow us to be compatible with Node's `os.uptime` - https://nodejs.org/api/os.html#osuptime Partially based on https://docs.rs/uptime_lib/latest/src/uptime_lib/lib.rs.html
This PR adds support for
Deno.uptime
which reports number of seconds since os was booted.It will allow us to be compatible with Node's
os.uptime
- https://nodejs.org/api/os.html#osuptimeThere's also
process.uptime
, but I believeDeno.uptime
should report stats for the OS itself, not the process, and we can always addDeno.processUptime
or similar method when it'll become necessary.Partially based on https://docs.rs/uptime_lib/latest/src/uptime_lib/lib.rs.html