| OLD | NEW |
| 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<ClassHeapStats> members; |
| 15 | 15 |
| 16 AllocationProfile(S.ServiceMap map) | 16 AllocationProfile(S.ServiceMap map) |
| 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 = map['members'].map(_convertMember).toList(); |
| 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 } | 34 } |
| 35 | 35 |
| 36 class ClassHeapStats implements M.ClassHeapStats { | 36 class ClassHeapStats implements M.ClassHeapStats { |
| 37 final S.Class clazz; | 37 final S.Class clazz; |
| 38 final S.Allocations newSpace; | 38 final S.Allocations newSpace; |
| 39 final S.Allocations oldSpace; | 39 final S.Allocations oldSpace; |
| 40 final int promotedInstances; | 40 final int promotedInstances; |
| 41 final int promotedBytes; | 41 final int promotedBytes; |
| 42 | 42 |
| 43 ClassHeapStats(S.ServiceMap map) | 43 ClassHeapStats(S.ServiceMap map) |
| 44 : clazz = map['class'], | 44 : clazz = map['class'], |
| 45 oldSpace = new S.Allocations()..update(map['old']), | 45 oldSpace = new S.Allocations()..update(map['old']), |
| 46 newSpace = new S.Allocations()..update(map['new']), | 46 newSpace = new S.Allocations()..update(map['new']), |
| 47 promotedInstances = map['promotedInstances'], | 47 promotedInstances = map['promotedInstances'], |
| 48 promotedBytes = map['promotedBytes']; | 48 promotedBytes = map['promotedBytes']; |
| 49 } | 49 } |
| OLD | NEW |