Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Unified Diff: runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart

Issue 2748403002: Added page to Observatory to display native memory allocation information. (Closed)
Patch Set: Added page to Observatory to display native memory allocation information. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart
diff --git a/runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart b/runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart
index 7617a20da4ada1bc6083171d19f10695b4699cf2..38fb04f7d9e195f5713ebc366ce8cc0055dd04cc 100644
--- a/runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart
+++ b/runtime/observatory/lib/src/elements/cpu_profile/virtual_tree.dart
@@ -7,7 +7,8 @@ import 'dart:html';
import 'dart:math' as Math;
import 'package:observatory/models.dart' as M;
import 'package:observatory/src/elements/stack_trace_tree_config.dart'
- show ProfileTreeMode;
+ show ProfileTreeMode,
+ ProfileTreeType;
import 'package:observatory/src/elements/code_ref.dart';
import 'package:observatory/src/elements/containers/virtual_tree.dart';
import 'package:observatory/src/elements/function_ref.dart';
@@ -16,7 +17,8 @@ import 'package:observatory/src/elements/helpers/tag.dart';
import 'package:observatory/utils.dart';
export 'package:observatory/src/elements/stack_trace_tree_config.dart'
- show ProfileTreeMode;
+ show ProfileTreeMode,
+ ProfileTreeType;
class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
static const tag =
@@ -29,12 +31,14 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
M.ProfileTreeDirection _direction;
ProfileTreeMode _mode;
+ ProfileTreeType _type;
M.IsolateRef _isolate;
M.SampleProfile _profile;
Iterable<M.CallTreeNodeFilter> _filters;
M.ProfileTreeDirection get direction => _direction;
ProfileTreeMode get mode => _mode;
+ ProfileTreeType get type => _type;
M.IsolateRef get isolate => _isolate;
M.SampleProfile get profile => _profile;
Iterable<M.CallTreeNodeFilter> get filters => _filters;
@@ -50,9 +54,9 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
factory CpuProfileVirtualTreeElement(
M.IsolateRef isolate, M.SampleProfile profile,
{ProfileTreeMode mode: ProfileTreeMode.function,
+ ProfileTreeType type: ProfileTreeType.cpu,
M.ProfileTreeDirection direction: M.ProfileTreeDirection.exclusive,
RenderingQueue queue}) {
- assert(isolate != null);
assert(profile != null);
assert(mode != null);
assert(direction != null);
@@ -61,6 +65,7 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
e._isolate = isolate;
e._profile = profile;
e._mode = mode;
+ e._type = type;
e._direction = direction;
return e;
}
@@ -84,15 +89,31 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
void render() {
var tree;
+ var create;
var update;
+
+ if (type == ProfileTreeType.cpu) {
+ create = _createCpuRow;
+ } else {
+ create = _createMemoryRow;
+ }
+
switch (mode) {
case ProfileTreeMode.code:
tree = _profile.loadCodeTree(_direction);
- update = _updateCodeRow;
+ if (type == ProfileTreeType.cpu) {
+ update = _updateCpuCodeRow;
+ } else {
Cutch 2017/03/21 20:27:10 } else if (type == ProfileTreeType.memory) { } els
bkonyi 2017/03/22 21:25:21 Done in the check above so we don't have to do it
+ update = _updateMemoryCodeRow;
+ }
break;
case ProfileTreeMode.function:
tree = _profile.loadFunctionTree(_direction);
- update = _updateFunctionRow;
+ if (type == ProfileTreeType.cpu) {
+ update = _updateCpuFunctionRow;
+ } else {
+ update = _updateMemoryFunctionRow;
Cutch 2017/03/21 20:27:10 ditto
bkonyi 2017/03/22 21:25:21 See above response.
+ }
break;
default:
throw new Exception('Unknown ProfileTreeMode: $mode');
@@ -106,7 +127,7 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
children = [new HeadingElement.h1()..text = 'No Results'];
return;
}
- _tree = new VirtualTreeElement(_createRow, update, _getChildren,
+ _tree = new VirtualTreeElement(create, update, _getChildren,
items: tree.root.children, queue: _r.queue);
if (tree.root.children.length == 1) {
_tree.expand(tree.root.children.first, autoExpandSingleChildNodes: true);
@@ -114,7 +135,7 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
children = [_tree];
}
- static Element _createRow(toggle) {
+ static Element _createCpuRow(toggle) {
return new DivElement()
..classes = ['tree-item']
..children = [
@@ -135,9 +156,30 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
];
}
+ static Element _createMemoryRow(toggle) {
+ return new DivElement()
+ ..classes = ['tree-item']
+ ..children = [
+ new SpanElement()
+ ..classes = ['inclusive']
+ ..title = 'memory allocated from resulting calls: ',
+ new SpanElement()
+ ..classes = ['exclusive']
+ ..title = 'memory allocated during execution: ',
+ new SpanElement()..classes = ['lines'],
+ new ButtonElement()
+ ..classes = ['expander']
+ ..onClick.listen((_) => toggle(autoToggleSingleChildNodes: true)),
+ new SpanElement()
+ ..classes = ['percentage']
+ ..title = 'tree node %',
+ new SpanElement()..classes = ['name']
+ ];
+ }
+
static _getChildren(M.CallTreeNode node) => node.children;
- void _updateFunctionRow(
+ void _updateCpuFunctionRow(
HtmlElement element, M.FunctionCallTreeNode item, int depth) {
element.children[0].text = Utils
.formatPercentNormalized(item.profileFunction.normalizedInclusiveTicks);
@@ -155,7 +197,30 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
..classes = ['name'];
}
- void _updateCodeRow(HtmlElement element, M.CodeCallTreeNode item, int depth) {
+ void _updateMemoryFunctionRow(
+ HtmlElement element, M.FunctionCallTreeNode item, int depth) {
+ element.children[0].text = Utils
+ .formatSize(item.inclusiveNativeAllocations);
+ element.children[0].title = 'memory allocated from resulting calls: ' +
+ '${item.inclusiveNativeAllocations}B';
+ element.children[1].text = Utils
+ .formatSize(item.exclusiveNativeAllocations);
+ element.children[1].title = 'memory allocated during execution: ' +
+ '${item.exclusiveNativeAllocations}B';
+ _updateLines(element.children[2].children, depth);
+ if (item.children.isNotEmpty) {
+ element.children[3].text = _tree.isExpanded(item) ? '▼' : '►';
+ } else {
+ element.children[3].text = '';
+ }
+ element.children[4].text =
+ Utils.formatPercentNormalized(item.percentage);
+ element.children[5] = new FunctionRefElement(
+ null, item.profileFunction.function, queue: _r.queue)
+ ..classes = ['name'];
+ }
+
+ void _updateCpuCodeRow(HtmlElement element, M.CodeCallTreeNode item, int depth) {
element.children[0].text = Utils
.formatPercentNormalized(item.profileCode.normalizedInclusiveTicks);
element.children[1].text = Utils
@@ -171,6 +236,27 @@ class CpuProfileVirtualTreeElement extends HtmlElement implements Renderable {
queue: _r.queue)..classes = ['name'];
}
+ void _updateMemoryCodeRow(HtmlElement element, M.CodeCallTreeNode item, int depth) {
Cutch 2017/03/21 20:27:10 long line..
bkonyi 2017/03/22 21:25:21 Done.
+ element.children[0].text = Utils
+ .formatSize(item.inclusiveNativeAllocations);
+ element.children[0].title = 'memory allocated from resulting calls: ' +
+ '${item.inclusiveNativeAllocations}B';
+ element.children[1].text = Utils
+ .formatSize(item.exclusiveNativeAllocations);
+ element.children[1].title = 'memory allocated during execution: ' +
+ '${item.exclusiveNativeAllocations}B';
+ _updateLines(element.children[2].children, depth);
+ if (item.children.isNotEmpty) {
+ element.children[3].text = _tree.isExpanded(item) ? '▼' : '►';
+ } else {
+ element.children[3].text = '';
+ }
+ element.children[4].text =
+ Utils.formatPercentNormalized(item.percentage);
+ element.children[5] = new CodeRefElement(null, item.profileCode.code,
+ queue: _r.queue)..classes = ['name'];
+ }
+
static _updateLines(List<Element> lines, int n) {
n = Math.max(0, n);
while (lines.length > n) {

Powered by Google App Engine
This is Rietveld 408576698