Skip to content

Commit

Permalink
feat: add process.getSystemVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Jan 29, 2019
1 parent 323b688 commit 7a1a614
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions atom/common/api/atom_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ void AtomBindings::BindProcess(v8::Isolate* isolate,
process->SetMethod("getHeapStatistics", &GetHeapStatistics);
process->SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
process->SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
process->SetMethod("getSystemVersion",
&base::SysInfo::OperatingSystemVersion);
process->SetMethod("getIOCounters", &GetIOCounters);
process->SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
base::Unretained(metrics)));
Expand Down
13 changes: 10 additions & 3 deletions docs/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In sandboxed renderers the `process` object contains only a subset of the APIs:
- `getHeapStatistics()`
- `getProcessMemoryInfo()`
- `getSystemMemoryInfo()`
- `getSystemVersion()`
- `getCPUUsage()`
- `getIOCounters()`
- `argv`
Expand Down Expand Up @@ -83,7 +84,7 @@ instead of the `--no-deprecation` command line flag.
### `process.enablePromiseAPIs`

A `Boolean` that controls whether or not deprecation warnings are printed to `stderr` when
formerly callback-based APIs converted to Promises are invoked using callbacks. Setting this to `true`
formerly callback-based APIs converted to Promises are invoked using callbacks. Setting this to `true`
will enable deprecation warnings.

### `process.resourcesPath`
Expand Down Expand Up @@ -173,7 +174,7 @@ Returns an object with V8 heap statistics. Note that all statistics are reported

Returns `Object`:

* `residentSet` Integer _Linux_ and _Windows_ - The amount of memory
* `residentSet` Integer _Linux_ and _Windows_ - The amount of memory
currently pinned to actual physical RAM in Kilobytes.
* `private` Integer - The amount of memory not shared by other processes, such as
JS heap or HTML content in Kilobytes.
Expand All @@ -184,7 +185,7 @@ Returns an object giving memory usage statistics about the current process. Note
that all statistics are reported in Kilobytes.
This api should be called after app ready.

Chromium does not provide `residentSet` value for macOS. This is because macOS
Chromium does not provide `residentSet` value for macOS. This is because macOS
performs in-memory compression of pages that haven't been recently used. As a
result the resident set size value is not what one would expect. `private` memory
is more representative of the actual pre-compression memory usage of the process
Expand All @@ -206,6 +207,12 @@ Returns `Object`:
Returns an object giving memory usage statistics about the entire system. Note
that all statistics are reported in Kilobytes.

### `process.getSystemVersion()`

Returns `String` - The version of the host operating system.

**Note:** It returns the actual operating system version instead of kernel version on macOS unlike `os.release()`.

### `process.takeHeapSnapshot(filePath)`

* `filePath` String - Path to the output file.
Expand Down
6 changes: 6 additions & 0 deletions spec/api-process-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ describe('process module', () => {
})
})

describe('process.getSystemVersion()', () => {
it('returns a string', () => {
expect(process.getSystemVersion()).to.be.a('string')
})
})

describe('process.getHeapStatistics()', () => {
it('returns heap statistics object', () => {
const heapStats = process.getHeapStatistics()
Expand Down

0 comments on commit 7a1a614

Please sign in to comment.