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: Add creationTime function to process #13542
Changes from 2 commits
e27592e
78b9aaf
c4cdfc9
14c452c
81d2dbd
9025cef
34bb5d4
9c03832
6deffff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,12 @@ The `process` object has the following methods: | |
|
||
Causes the main thread of the current process crash. | ||
|
||
### `process.getCreationTime()` | ||
|
||
Returns [`number`] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And btw there's no reasons to have square brackets there ) |
||
Indicates the creation time of the application. | ||
The time is represented as microseconds (s/1,000,000) since the Windows epoch (1601-01-01 00:00:00 UTC) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mac & linux seem to return seconds from the start of the process. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the run from Mac it is giving back time since windows epoch as well Comment from time.h in chromium / Time represents an absolute point in coordinated universal time (UTC), There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The returned value should be easy to use in JavaScript. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please return |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to document this as "Returns
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done @ckerr There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment got misplaced, no menu stuff here 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MarshallOfSound you're correct, that should've read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @husayn I don't know if it the capitalization is required, but all our other documentation instances use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ckerr capitalized it. |
||
### `process.getCPUUsage()` | ||
|
||
Returns [`CPUUsage`](structures/cpu-usage.md) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
const assert = require('assert') | ||
|
||
describe('process module', () => { | ||
describe('process.getCreationTime()', () => { | ||
it('returns a creation time', () => { | ||
const creationTime = process.getCreationTime() | ||
assert.equal(typeof creationTime, 'number') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use const {expect} = require('chai') // On the top of the file.
...
expect(creationTime).to.be.a('number').and.be.at.least(0) |
||
}) | ||
}) | ||
|
||
describe('process.getCPUUsage()', () => { | ||
it('returns a cpu usage object', () => { | ||
const cpuUsage = process.getCPUUsage() | ||
|
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.
this is deprecated
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.
Should probably use
base::CurrentProcessInfo::CreationTime().ToJsTime()
Refs:
ToJsTime()
Then users can just do
new Date()
on the ret value to get a JS dateThere 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.
Bonus points for a new
mate
converter tov8::Date
https://v8docs.nodesource.com/node-0.8/d4/df7/classv8_1_1_date.html
I.e. Convert
base::Time
tov8::Date