| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 part of allocation_profiler; |
| 6 |
| 7 class AllocationProfile implements M.AllocationProfile { |
| 8 static const _lastServiceGC = 'dateLastServiceGC'; |
| 9 final DateTime lastServiceGC; |
| 10 static const _lastAccumulatorReset = 'dateLastAccumulatorReset'; |
| 11 final DateTime lastAccumulatorReset; |
| 12 final S.HeapSpace newSpace; |
| 13 final S.HeapSpace oldSpace; |
| 14 final Iterable<ClassHeapStats> members; |
| 15 |
| 16 AllocationProfile(S.ServiceMap map) |
| 17 : lastAccumulatorReset = _intString2DateTime(map[_lastAccumulatorReset]), |
| 18 lastServiceGC = _intString2DateTime(map[_lastServiceGC]), |
| 19 oldSpace = new S.HeapSpace()..update(map['heaps']['old']), |
| 20 newSpace = new S.HeapSpace()..update(map['heaps']['new']), |
| 21 members = map['members'].map(_convertMember).toList(); |
| 22 |
| 23 static DateTime _intString2DateTime(String milliseconds) { |
| 24 if ((milliseconds == null) || milliseconds == '') { |
| 25 return null; |
| 26 } |
| 27 return new DateTime.fromMillisecondsSinceEpoch(int.parse(milliseconds)); |
| 28 } |
| 29 |
| 30 static ClassHeapStats _convertMember(S.ServiceMap map) { |
| 31 assert(map['type'] == 'ClassHeapStats'); |
| 32 return new ClassHeapStats(map); |
| 33 } |
| 34 } |
| 35 |
| 36 class ClassHeapStats implements M.ClassHeapStats { |
| 37 final S.Class clazz; |
| 38 final S.Allocations newSpace; |
| 39 final S.Allocations oldSpace; |
| 40 final int promotedInstances; |
| 41 final int promotedBytes; |
| 42 |
| 43 ClassHeapStats(S.ServiceMap map) |
| 44 : clazz = map['class'], |
| 45 oldSpace = new S.Allocations()..update(map['old']), |
| 46 newSpace = new S.Allocations()..update(map['new']), |
| 47 promotedInstances = map['promotedInstances'], |
| 48 promotedBytes = map['promotedBytes']; |
| 49 } |
| OLD | NEW |