| 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 /// A script to track the high water-mark of memory usage of an application. | 5 /// A script to track the high water-mark of memory usage of an application. |
| 6 /// To monitor how much memory dart2js is using, run dart2js as follows: | 6 /// To monitor how much memory dart2js is using, run dart2js as follows: |
| 7 /// | 7 /// |
| 8 /// DART_VM_OPTIONS=--observe dart2js ... | 8 /// DART_VM_OPTIONS=--observe dart2js ... |
| 9 /// | 9 /// |
| 10 /// and run this script immediately after. | 10 /// and run this script immediately after. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 sb.write(' | '); | 144 sb.write(' | '); |
| 145 _writeNumber(sb, lastOldUsed, oldUsed); | 145 _writeNumber(sb, lastOldUsed, oldUsed); |
| 146 _writeNumber(sb, lastOldCapacity, oldCapacity, color: true); | 146 _writeNumber(sb, lastOldCapacity, oldCapacity, color: true); |
| 147 | 147 |
| 148 sb.write(' | '); | 148 sb.write(' | '); |
| 149 _writeNumber(sb, lastNewUsed + lastOldUsed, newUsed + oldUsed); | 149 _writeNumber(sb, lastNewUsed + lastOldUsed, newUsed + oldUsed); |
| 150 _writeNumber(sb, lastNewCapacity + lastOldCapacity, newCapacity + oldCapacity, | 150 _writeNumber(sb, lastNewCapacity + lastOldCapacity, newCapacity + oldCapacity, |
| 151 color: true); | 151 color: true); |
| 152 | 152 |
| 153 sb.write(' | '); | 153 sb.write(' | '); |
| 154 var maxUsed = max(lastMaxUsed, newUsed + oldUsed); | 154 int maxUsed = max(lastMaxUsed, newUsed + oldUsed); |
| 155 var maxCapacity = max(lastMaxCapacity, newCapacity + oldCapacity); | 155 int maxCapacity = max(lastMaxCapacity, newCapacity + oldCapacity); |
| 156 _writeNumber(sb, lastMaxUsed, maxUsed); | 156 _writeNumber(sb, lastMaxUsed, maxUsed); |
| 157 _writeNumber(sb, lastMaxCapacity, maxCapacity, color: true); | 157 _writeNumber(sb, lastMaxCapacity, maxCapacity, color: true); |
| 158 stdout.write('$sb'); | 158 stdout.write('$sb'); |
| 159 | 159 |
| 160 lastNewUsed = newUsed; | 160 lastNewUsed = newUsed; |
| 161 lastOldUsed = oldUsed; | 161 lastOldUsed = oldUsed; |
| 162 lastMaxUsed = maxUsed; | 162 lastMaxUsed = maxUsed; |
| 163 lastNewCapacity = newCapacity; | 163 lastNewCapacity = newCapacity; |
| 164 lastOldCapacity = oldCapacity; | 164 lastOldCapacity = oldCapacity; |
| 165 lastMaxCapacity = maxCapacity; | 165 lastMaxCapacity = maxCapacity; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 185 _printHeader() { | 185 _printHeader() { |
| 186 print(''' | 186 print(''' |
| 187 Memory usage: | 187 Memory usage: |
| 188 new generation | old generation | total | max | 188 new generation | old generation | total | max |
| 189 in-use/capacity | in-use/capacity | in-use/capacity | in-use/capacity '''); | 189 in-use/capacity | in-use/capacity | in-use/capacity | in-use/capacity '''); |
| 190 } | 190 } |
| 191 | 191 |
| 192 const _RED = '\x1b[31m'; | 192 const _RED = '\x1b[31m'; |
| 193 const _GREEN = '\x1b[32m'; | 193 const _GREEN = '\x1b[32m'; |
| 194 const _NONE = '\x1b[0m'; | 194 const _NONE = '\x1b[0m'; |
| OLD | NEW |