Skip to content

Commit

Permalink
DevTools: Make performance monitor report a single process memory again.
Browse files Browse the repository at this point in the history
BUG=832364

Change-Id: I4baf520742f740bc296eb12ce76d9e82796f9f9a
Reviewed-on: https://chromium-review.googlesource.com/1011586
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550704}
  • Loading branch information
a1ph authored and Commit Bot committed Apr 13, 2018
1 parent 9704fe0 commit c96d64e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Tests list of performance metrics and that memory is not double counted.
Tests stability of performance metrics list.


Metrics reported:
Expand Down Expand Up @@ -31,11 +31,3 @@ UACSSResources
V8PerContextDatas
WorkerGlobalScopes

Targets after navigate
Main
iframe.html
inner-iframe.html
inner-iframe.html

metrics size is twice smaller than simple sum: true

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

(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);
await model.enable();
Expand All @@ -12,21 +12,5 @@
TestRunner.addResult('\nMetrics reported:');
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();
})();
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,8 @@ SDK.PerformanceMetricsModel = class extends SDK.SDKModel {
}
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 {!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} */
Expand Down

0 comments on commit c96d64e

Please sign in to comment.