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

Unified Diff: runtime/observatory/lib/src/allocation_profile/allocation_profile.dart

Issue 3003903002: Hide internal classes from Memory Profile (Closed)
Patch Set: Address CL comments Created 3 years, 4 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
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/memory/allocations.dart » ('j') | runtime/vm/service.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/allocation_profile/allocation_profile.dart
diff --git a/runtime/observatory/lib/src/allocation_profile/allocation_profile.dart b/runtime/observatory/lib/src/allocation_profile/allocation_profile.dart
index 1f7cff1115d3cb861905709c12370acd9e43df87..b8f9f0329f7b14535b08dc051e17091f9961d71f 100644
--- a/runtime/observatory/lib/src/allocation_profile/allocation_profile.dart
+++ b/runtime/observatory/lib/src/allocation_profile/allocation_profile.dart
@@ -11,14 +11,14 @@ class AllocationProfile implements M.AllocationProfile {
final DateTime lastAccumulatorReset;
final S.HeapSpace newSpace;
final S.HeapSpace oldSpace;
- final Iterable<ClassHeapStats> members;
+ final Iterable<M.ClassHeapStats> members;
- AllocationProfile(S.ServiceMap map)
+ AllocationProfile(S.ServiceMap map, {Map<String, List<String>> defaults})
: lastAccumulatorReset = _intString2DateTime(map[_lastAccumulatorReset]),
lastServiceGC = _intString2DateTime(map[_lastServiceGC]),
oldSpace = new S.HeapSpace()..update(map['heaps']['old']),
newSpace = new S.HeapSpace()..update(map['heaps']['new']),
- members = map['members'].map(_convertMember).toList();
+ members = _convertMembers(map['members'], defaults: defaults);
static DateTime _intString2DateTime(String milliseconds) {
if ((milliseconds == null) || milliseconds == '') {
@@ -31,10 +31,38 @@ class AllocationProfile implements M.AllocationProfile {
assert(map['type'] == 'ClassHeapStats');
return new ClassHeapStats(map);
}
+
+ static List<M.ClassHeapStats> _convertMembers(Iterable<S.ServiceMap> raw,
+ {Map<String, List<String>> defaults}) {
+ final List<M.ClassHeapStats> members = raw.map(_convertMember).toList();
+ if (defaults == null) {
+ return members;
+ }
+ final Map<String, List<ClassHeapStats>> aliases =
+ new Map.fromIterable(defaults.keys, value: (_) => <ClassHeapStats>[]);
+ final Map<String, List<ClassHeapStats>> accumulators =
+ <String, List<ClassHeapStats>>{};
+ defaults.forEach((String key, List<String> values) {
+ final classes = aliases[key];
+ accumulators.addAll(new Map.fromIterable(values, value: (_) => classes));
+ });
+ final List<M.ClassHeapStats> result = <M.ClassHeapStats>[];
+ members.forEach((ClassHeapStats member) {
+ if (accumulators.containsKey(member.clazz.id)) {
+ accumulators[member.clazz.id].add(member);
+ } else {
+ result.add(member);
+ }
+ });
+ return result
+ ..addAll(
+ aliases.keys.map((key) => new ClassesHeapStats(key, aliases[key])));
+ }
}
class ClassHeapStats implements M.ClassHeapStats {
final S.Class clazz;
+ final String displayName = null;
final S.Allocations newSpace;
final S.Allocations oldSpace;
final int promotedInstances;
@@ -47,3 +75,18 @@ class ClassHeapStats implements M.ClassHeapStats {
promotedInstances = map['promotedInstances'],
promotedBytes = map['promotedBytes'];
}
+
+class ClassesHeapStats implements M.ClassHeapStats {
+ final S.Class clazz = null;
+ final String displayName;
+ final S.Allocations newSpace;
+ final S.Allocations oldSpace;
+ final int promotedInstances;
+ final int promotedBytes;
+
+ ClassesHeapStats(this.displayName, Iterable<ClassHeapStats> classes)
+ : oldSpace = new S.Allocations()..combine(classes.map((m) => m.oldSpace)),
+ newSpace = new S.Allocations()..combine(classes.map((m) => m.newSpace)),
+ promotedInstances = classes.fold(0, (v, m) => v + m.promotedInstances),
+ promotedBytes = classes.fold(0, (v, m) => v + m.promotedBytes);
+}
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/memory/allocations.dart » ('j') | runtime/vm/service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698