| 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);
|
| +}
|
|
|