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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of allocation_profiler; 5 part of allocation_profiler;
6 6
7 class AllocationProfile implements M.AllocationProfile { 7 class AllocationProfile implements M.AllocationProfile {
8 static const _lastServiceGC = 'dateLastServiceGC'; 8 static const _lastServiceGC = 'dateLastServiceGC';
9 final DateTime lastServiceGC; 9 final DateTime lastServiceGC;
10 static const _lastAccumulatorReset = 'dateLastAccumulatorReset'; 10 static const _lastAccumulatorReset = 'dateLastAccumulatorReset';
11 final DateTime lastAccumulatorReset; 11 final DateTime lastAccumulatorReset;
12 final S.HeapSpace newSpace; 12 final S.HeapSpace newSpace;
13 final S.HeapSpace oldSpace; 13 final S.HeapSpace oldSpace;
14 final Iterable<ClassHeapStats> members; 14 final Iterable<M.ClassHeapStats> members;
15 15
16 AllocationProfile(S.ServiceMap map) 16 AllocationProfile(S.ServiceMap map, {Map<String, List<String>> defaults})
17 : lastAccumulatorReset = _intString2DateTime(map[_lastAccumulatorReset]), 17 : lastAccumulatorReset = _intString2DateTime(map[_lastAccumulatorReset]),
18 lastServiceGC = _intString2DateTime(map[_lastServiceGC]), 18 lastServiceGC = _intString2DateTime(map[_lastServiceGC]),
19 oldSpace = new S.HeapSpace()..update(map['heaps']['old']), 19 oldSpace = new S.HeapSpace()..update(map['heaps']['old']),
20 newSpace = new S.HeapSpace()..update(map['heaps']['new']), 20 newSpace = new S.HeapSpace()..update(map['heaps']['new']),
21 members = map['members'].map(_convertMember).toList(); 21 members = _convertMembers(map['members'], defaults: defaults);
22 22
23 static DateTime _intString2DateTime(String milliseconds) { 23 static DateTime _intString2DateTime(String milliseconds) {
24 if ((milliseconds == null) || milliseconds == '') { 24 if ((milliseconds == null) || milliseconds == '') {
25 return null; 25 return null;
26 } 26 }
27 return new DateTime.fromMillisecondsSinceEpoch(int.parse(milliseconds)); 27 return new DateTime.fromMillisecondsSinceEpoch(int.parse(milliseconds));
28 } 28 }
29 29
30 static ClassHeapStats _convertMember(S.ServiceMap map) { 30 static ClassHeapStats _convertMember(S.ServiceMap map) {
31 assert(map['type'] == 'ClassHeapStats'); 31 assert(map['type'] == 'ClassHeapStats');
32 return new ClassHeapStats(map); 32 return new ClassHeapStats(map);
33 } 33 }
34
35 static List<M.ClassHeapStats> _convertMembers(Iterable<S.ServiceMap> raw,
36 {Map<String, List<String>> defaults}) {
37 final List<M.ClassHeapStats> members = raw.map(_convertMember).toList();
38 if (defaults == null) {
39 return members;
40 }
41 final Map<String, List<ClassHeapStats>> aliases =
42 new Map.fromIterable(defaults.keys, value: (_) => <ClassHeapStats>[]);
43 final Map<String, List<ClassHeapStats>> accumulators =
44 <String, List<ClassHeapStats>>{};
45 defaults.forEach((String key, List<String> values) {
46 final classes = aliases[key];
47 accumulators.addAll(new Map.fromIterable(values, value: (_) => classes));
48 });
49 final List<M.ClassHeapStats> result = <M.ClassHeapStats>[];
50 members.forEach((ClassHeapStats member) {
51 if (accumulators.containsKey(member.clazz.id)) {
52 accumulators[member.clazz.id].add(member);
53 } else {
54 result.add(member);
55 }
56 });
57 return result
58 ..addAll(
59 aliases.keys.map((key) => new ClassesHeapStats(key, aliases[key])));
60 }
34 } 61 }
35 62
36 class ClassHeapStats implements M.ClassHeapStats { 63 class ClassHeapStats implements M.ClassHeapStats {
37 final S.Class clazz; 64 final S.Class clazz;
65 final String displayName = null;
38 final S.Allocations newSpace; 66 final S.Allocations newSpace;
39 final S.Allocations oldSpace; 67 final S.Allocations oldSpace;
40 final int promotedInstances; 68 final int promotedInstances;
41 final int promotedBytes; 69 final int promotedBytes;
42 70
43 ClassHeapStats(S.ServiceMap map) 71 ClassHeapStats(S.ServiceMap map)
44 : clazz = map['class'], 72 : clazz = map['class'],
45 oldSpace = new S.Allocations()..update(map['old']), 73 oldSpace = new S.Allocations()..update(map['old']),
46 newSpace = new S.Allocations()..update(map['new']), 74 newSpace = new S.Allocations()..update(map['new']),
47 promotedInstances = map['promotedInstances'], 75 promotedInstances = map['promotedInstances'],
48 promotedBytes = map['promotedBytes']; 76 promotedBytes = map['promotedBytes'];
49 } 77 }
78
79 class ClassesHeapStats implements M.ClassHeapStats {
80 final S.Class clazz = null;
81 final String displayName;
82 final S.Allocations newSpace;
83 final S.Allocations oldSpace;
84 final int promotedInstances;
85 final int promotedBytes;
86
87 ClassesHeapStats(this.displayName, Iterable<ClassHeapStats> classes)
88 : oldSpace = new S.Allocations()..combine(classes.map((m) => m.oldSpace)),
89 newSpace = new S.Allocations()..combine(classes.map((m) => m.newSpace)),
90 promotedInstances = classes.fold(0, (v, m) => v + m.promotedInstances),
91 promotedBytes = classes.fold(0, (v, m) => v + m.promotedBytes);
92 }
OLDNEW
« 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