Commit c96d64ef authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Make performance monitor report a single process memory again.

BUG=832364

Change-Id: I4baf520742f740bc296eb12ce76d9e82796f9f9a
Reviewed-on: https://chromium-review.googlesource.com/1011586Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550704}
parent 9704fe05
Tests list of performance metrics and that memory is not double counted. Tests stability of performance metrics list.
Metrics reported: Metrics reported:
...@@ -31,11 +31,3 @@ UACSSResources ...@@ -31,11 +31,3 @@ UACSSResources
V8PerContextDatas V8PerContextDatas
WorkerGlobalScopes WorkerGlobalScopes
Targets after navigate
Main
iframe.html
inner-iframe.html
inner-iframe.html
metrics size is twice smaller than simple sum: true
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
TestRunner.addResult(`Tests list of performance metrics and that memory is not double counted.\n`); TestRunner.addResult(`Tests stability of performance metrics list.\n`);
const model = SDK.targetManager.mainTarget().model(SDK.PerformanceMetricsModel); const model = SDK.targetManager.mainTarget().model(SDK.PerformanceMetricsModel);
await model.enable(); await model.enable();
...@@ -12,21 +12,5 @@ ...@@ -12,21 +12,5 @@
TestRunner.addResult('\nMetrics reported:'); TestRunner.addResult('\nMetrics reported:');
TestRunner.addResults(metrics.keysArray().sort()); TestRunner.addResults(metrics.keysArray().sort());
await TestRunner.navigatePromise('resources/page.html');
TestRunner.addResult('\nTargets after navigate');
TestRunner.addResults(SDK.targetManager.targets().map(t => t.name()).sort());
let lastTotal, total;
do {
metrics = (await model.requestMetrics()).metrics;
lastTotal = total;
total = 0;
for (const m of SDK.targetManager.models(SDK.RuntimeModel))
total += (await m.heapUsage()).totalSize;
} while (total !== lastTotal);
TestRunner.addResult('\nmetrics size is twice smaller than simple sum: ' +
(metrics.get('JSHeapTotalSize') * 2 === total));
TestRunner.completeTest(); TestRunner.completeTest();
})(); })();
...@@ -71,31 +71,8 @@ SDK.PerformanceMetricsModel = class extends SDK.SDKModel { ...@@ -71,31 +71,8 @@ SDK.PerformanceMetricsModel = class extends SDK.SDKModel {
} }
metrics.set(metric.name, value); metrics.set(metric.name, value);
} }
const totalMemoryUsage = await this._requestTotalMemory();
metrics.set('JSHeapUsedSize', totalMemoryUsage.usedSize);
metrics.set('JSHeapTotalSize', totalMemoryUsage.totalSize);
return {metrics: metrics, timestamp: timestamp}; return {metrics: metrics, timestamp: timestamp};
} }
/**
* @return {!Promise<!{usedSize: number, totalSize: number}>}
*/
async _requestTotalMemory() {
const models = SDK.targetManager.models(SDK.RuntimeModel);
const isolates = await Promise.all(models.map(model => model.isolateId()));
/** @type {!Map<string, !SDK.RuntimeModel>} */
const modelsByIsolate = new Map();
for (let i = 0; i < isolates.length; ++i)
modelsByIsolate.set(isolates[i], models[i]);
const usages = await Promise.all(modelsByIsolate.valuesArray().map(model => model.heapUsage()));
let totalSize = 0;
let usedSize = 0;
for (const usage of usages) {
totalSize += usage ? usage.totalSize : 0;
usedSize += usage ? usage.usedSize : 0;
}
return {totalSize, usedSize};
}
}; };
/** @enum {symbol} */ /** @enum {symbol} */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment