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 'dart:collection'; | 5 import 'dart:collection'; |
6 | 6 |
7 import '../log/log.dart'; | 7 import '../log/log.dart'; |
8 import 'page_writer.dart'; | 8 import 'page_writer.dart'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 * Initialize a newly created page writer to write information about the given | 45 * Initialize a newly created page writer to write information about the given |
46 * instrumentation [log]. | 46 * instrumentation [log]. |
47 */ | 47 */ |
48 StatsPage(this.log) { | 48 StatsPage(this.log) { |
49 _processEntries(log.logEntries); | 49 _processEntries(log.logEntries); |
50 } | 50 } |
51 | 51 |
52 @override | 52 @override |
53 void writeBody(StringSink sink) { | 53 void writeBody(StringSink sink) { |
54 writeMenu(sink); | 54 writeMenu(sink); |
55 sink.writeln('<div id="container">'); | 55 writeTwoColumns( |
56 sink.writeln(' <div id="content">'); | 56 sink, 'leftColumn', _writeLeftColumn, 'rightColumn', _writeRightColumn); |
57 sink.writeln(' <div id="leftColumn">'); | |
58 sink.writeln(' <div class="inset">'); | |
59 _writeLeftColumn(sink); | |
60 sink.writeln(' </div>'); | |
61 sink.writeln(' </div>'); | |
62 sink.writeln(' <div id="rightColumn">'); | |
63 sink.writeln(' <div class="inset">'); | |
64 _writeRightColumn(sink); | |
65 sink.writeln(' </div>'); | |
66 sink.writeln(' </div>'); | |
67 sink.writeln(' </div>'); | |
68 sink.writeln('</div>'); | |
69 } | 57 } |
70 | 58 |
71 /** | 59 /** |
72 * Write the content of the style sheet (without the 'script' tag) for the | 60 * Write the content of the style sheet (without the 'script' tag) for the |
73 * page to the given [sink]. | 61 * page to the given [sink]. |
74 */ | 62 */ |
75 void writeStyleSheet(StringSink sink) { | 63 void writeStyleSheet(StringSink sink) { |
76 super.writeStyleSheet(sink); | 64 super.writeStyleSheet(sink); |
77 sink.writeln(r''' | 65 writeTwoColumnStyles(sink, 'leftColumn', 'rightColumn'); |
78 #leftColumn { | |
79 float: left; | |
80 height: 100%; | |
81 overflow: auto; | |
82 width: 50%; | |
83 } | |
84 #rightColumn { | |
85 float: right; | |
86 height: 100%; | |
87 overflow: auto; | |
88 width: 50%; | |
89 } | |
90 '''); | |
91 } | 66 } |
92 | 67 |
93 /** | 68 /** |
94 * Return the mean of the values in the given list of [values]. | 69 * Return the mean of the values in the given list of [values]. |
95 */ | 70 */ |
96 int _mean(List<int> values) { | 71 int _mean(List<int> values) { |
97 int sum = values.fold(0, (int sum, int latency) => sum + latency); | 72 int sum = values.fold(0, (int sum, int latency) => sum + latency); |
98 return sum ~/ values.length; | 73 return sum ~/ values.length; |
99 } | 74 } |
100 | 75 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 sink.write('<p>'); | 198 sink.write('<p>'); |
224 sink.write('<span class="label">Time to first notification:</span> '); | 199 sink.write('<span class="label">Time to first notification:</span> '); |
225 sink.write(completionResponseTimes[0]); | 200 sink.write(completionResponseTimes[0]); |
226 sink.write(', '); | 201 sink.write(', '); |
227 sink.write(_mean(completionResponseTimes)); | 202 sink.write(_mean(completionResponseTimes)); |
228 sink.write(', '); | 203 sink.write(', '); |
229 sink.write(completionResponseTimes[completionResponseTimes.length - 1]); | 204 sink.write(completionResponseTimes[completionResponseTimes.length - 1]); |
230 sink.writeln('</p>'); | 205 sink.writeln('</p>'); |
231 } | 206 } |
232 } | 207 } |
OLD | NEW |