OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import '../log/log.dart'; | 5 import '../log/log.dart'; |
6 import 'page_writer.dart'; | 6 import 'page_writer.dart'; |
7 | 7 |
8 /** | 8 /** |
9 * A page writer that will produce the page containing statistics about an | 9 * A page writer that will produce the page containing statistics about an |
10 * instrumentation log. | 10 * instrumentation log. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 int _mean(List<int> values) { | 82 int _mean(List<int> values) { |
83 int sum = values.fold(0, (int sum, int latency) => sum + latency); | 83 int sum = values.fold(0, (int sum, int latency) => sum + latency); |
84 return sum ~/ values.length; | 84 return sum ~/ values.length; |
85 } | 85 } |
86 | 86 |
87 /** | 87 /** |
88 * Return a table mapping the kinds of the given [entries] to the number of | 88 * Return a table mapping the kinds of the given [entries] to the number of |
89 * each kind. | 89 * each kind. |
90 */ | 90 */ |
91 void _processEntries(List<LogEntry> entries) { | 91 void _processEntries(List<LogEntry> entries) { |
92 void increment/*<K>*/(Map<dynamic/*=K*/, int> map, dynamic/*=K*/ key) { | 92 void increment<K>(Map<K, int> map, K key) { |
93 map[key] = (map[key] ?? 0) + 1; | 93 map[key] = (map[key] ?? 0) + 1; |
94 } | 94 } |
95 | 95 |
96 for (LogEntry entry in entries) { | 96 for (LogEntry entry in entries) { |
97 String kind = entry.kind; | 97 String kind = entry.kind; |
98 increment(entryCounts, kind); | 98 increment(entryCounts, kind); |
99 if (entry is ResponseEntry) { | 99 if (entry is ResponseEntry) { |
100 if (entry.result('error') != null) { | 100 if (entry.result('error') != null) { |
101 errorCount++; | 101 errorCount++; |
102 } | 102 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 sink.write(responseTimes[responseTimes.length - 1]); | 256 sink.write(responseTimes[responseTimes.length - 1]); |
257 sink.write('</td><td>'); | 257 sink.write('</td><td>'); |
258 sink.write(method); | 258 sink.write(method); |
259 sink.writeln('</td></tr>'); | 259 sink.writeln('</td></tr>'); |
260 } | 260 } |
261 sink.writeln('</table>'); | 261 sink.writeln('</table>'); |
262 }); | 262 }); |
263 } | 263 } |
264 } | 264 } |
265 } | 265 } |
OLD | NEW |