Remove the memory property from getAppMetrics
See 03d0bfd593
for more information
This commit is contained in:
parent
14df89f214
commit
dde194d853
5 changed files with 4 additions and 35 deletions
|
@ -1112,30 +1112,11 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||||
|
|
||||||
for (const auto& process_metric : app_metrics_) {
|
for (const auto& process_metric : app_metrics_) {
|
||||||
mate::Dictionary pid_dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary pid_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate);
|
|
||||||
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
|
|
||||||
pid_dict.SetHidden("simple", true);
|
pid_dict.SetHidden("simple", true);
|
||||||
memory_dict.SetHidden("simple", true);
|
|
||||||
cpu_dict.SetHidden("simple", true);
|
cpu_dict.SetHidden("simple", true);
|
||||||
|
|
||||||
memory_dict.Set(
|
|
||||||
"workingSetSize",
|
|
||||||
static_cast<double>(
|
|
||||||
process_metric.second->metrics->GetWorkingSetSize() >> 10));
|
|
||||||
memory_dict.Set(
|
|
||||||
"peakWorkingSetSize",
|
|
||||||
static_cast<double>(
|
|
||||||
process_metric.second->metrics->GetPeakWorkingSetSize() >> 10));
|
|
||||||
|
|
||||||
size_t private_bytes, shared_bytes;
|
|
||||||
if (process_metric.second->metrics->GetMemoryBytes(&private_bytes,
|
|
||||||
&shared_bytes)) {
|
|
||||||
memory_dict.Set("privateBytes", static_cast<double>(private_bytes >> 10));
|
|
||||||
memory_dict.Set("sharedBytes", static_cast<double>(shared_bytes >> 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
pid_dict.Set("memory", memory_dict);
|
|
||||||
cpu_dict.Set(
|
cpu_dict.Set(
|
||||||
"percentCPUUsage",
|
"percentCPUUsage",
|
||||||
process_metric.second->metrics->GetPlatformIndependentCPUUsage() /
|
process_metric.second->metrics->GetPlatformIndependentCPUUsage() /
|
||||||
|
|
|
@ -49,9 +49,7 @@ app.getAppMetrics()
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
const metrics = app.getAppMetrics()
|
const metrics = app.getAppMetrics()
|
||||||
const {memory} = metrics[0]
|
const {memory} = metrics[0] // Deprecated property
|
||||||
memory.privateBytes // Deprecated property
|
|
||||||
memory.sharedBytes // Deprecated property
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## `BrowserWindow`
|
## `BrowserWindow`
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
|
|
||||||
* `pid` Integer - Process id of the process.
|
* `pid` Integer - Process id of the process.
|
||||||
* `type` String - Process type (Browser or Tab or GPU etc).
|
* `type` String - Process type (Browser or Tab or GPU etc).
|
||||||
* `memory` [MemoryInfo](memory-info.md) - Memory information for the process.
|
|
||||||
* `cpu` [CPUUsage](cpu-usage.md) - CPU usage of the process.
|
* `cpu` [CPUUsage](cpu-usage.md) - CPU usage of the process.
|
||||||
|
|
|
@ -43,9 +43,8 @@ Object.assign(app, {
|
||||||
const nativeFn = app.getAppMetrics
|
const nativeFn = app.getAppMetrics
|
||||||
app.getAppMetrics = () => {
|
app.getAppMetrics = () => {
|
||||||
let metrics = nativeFn.call(app)
|
let metrics = nativeFn.call(app)
|
||||||
for (const {memory} of metrics) {
|
for (const metric of metrics) {
|
||||||
deprecate.removeProperty(memory, 'privateBytes')
|
deprecate.removeProperty(metric, 'memory')
|
||||||
deprecate.removeProperty(memory, 'sharedBytes')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return metrics
|
return metrics
|
||||||
|
|
|
@ -786,15 +786,7 @@ describe('app module', () => {
|
||||||
expect(appMetrics).to.be.an('array').and.have.lengthOf.at.least(1, 'App memory info object is not > 0')
|
expect(appMetrics).to.be.an('array').and.have.lengthOf.at.least(1, 'App memory info object is not > 0')
|
||||||
|
|
||||||
const types = []
|
const types = []
|
||||||
for (const {memory, pid, type, cpu} of appMetrics) {
|
for (const {pid, type, cpu} of appMetrics) {
|
||||||
expect(memory.workingSetSize).to.be.above(0, 'working set size is not > 0')
|
|
||||||
|
|
||||||
// windows causes failures here due to CI server configuration
|
|
||||||
if (process.platform !== 'win32') {
|
|
||||||
expect(memory.privateBytes).to.be.above(0, 'private bytes is not > 0')
|
|
||||||
expect(memory.sharedBytes).to.be.above(0, 'shared bytes is not > 0')
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(pid).to.be.above(0, 'pid is not > 0')
|
expect(pid).to.be.above(0, 'pid is not > 0')
|
||||||
expect(type).to.be.a('string').that.is.not.empty()
|
expect(type).to.be.a('string').that.is.not.empty()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue