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 library protoc.benchmark.dashboard_model; | 5 library protoc.benchmark.dashboard_model; |
6 | 6 |
7 import 'generated/benchmark.pb.dart' as pb; | 7 import 'generated/benchmark.pb.dart' as pb; |
8 | 8 |
9 import 'benchmark.dart' show Benchmark; | 9 import 'benchmark.dart' show Benchmark; |
10 import 'benchmarks/index.dart' show createBenchmark; | 10 import 'benchmarks/index.dart' show createBenchmark; |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 /// The parts of the benchmark results table that don't change often. | 35 /// The parts of the benchmark results table that don't change often. |
36 class Table { | 36 class Table { |
37 final pb.Suite suite; | 37 final pb.Suite suite; |
38 final String baseline; | 38 final String baseline; |
39 final pb.Report report; | 39 final pb.Report report; |
40 final Set<pb.Request> selections; | 40 final Set<pb.Request> selections; |
41 final rows = <Row>[]; | 41 final rows = <Row>[]; |
42 | 42 |
43 factory Table(pb.Suite suite) => | 43 factory Table(pb.Suite suite) => new Table._raw( |
44 new Table._raw(suite, null, null, new Set<pb.Request>.from(suite.requests)); | 44 suite, null, null, new Set<pb.Request>.from(suite.requests)); |
45 | 45 |
46 Table._raw(this.suite, this.baseline, this.report, this.selections) { | 46 Table._raw(this.suite, this.baseline, this.report, this.selections) { |
47 var it = report == null ? [].iterator : report.responses.iterator; | 47 Iterator it = report == null ? [].iterator : report.responses.iterator; |
48 for (var r in suite.requests) { | 48 for (var r in suite.requests) { |
49 var b = createBenchmark(r); | 49 var b = createBenchmark(r); |
50 pb.Sample baseline; | 50 pb.Sample baseline; |
51 if (it.moveNext()) { | 51 if (it.moveNext()) { |
52 b.checkRequest(it.current.request); | 52 b.checkRequest(it.current.request); |
53 baseline = b.medianSample(it.current); | 53 baseline = b.medianSample(it.current); |
54 } | 54 } |
55 rows.add(new Row(r, b, baseline, selected: this.selections.contains(r))); | 55 rows.add(new Row(r, b, baseline, selected: this.selections.contains(r))); |
56 } | 56 } |
57 } | 57 } |
58 | 58 |
59 Table withBaseline(String baseline, pb.Report report) => | 59 Table withBaseline(String baseline, pb.Report report) => |
60 new Table._raw(suite, baseline, report, selections); | 60 new Table._raw(suite, baseline, report, selections); |
61 | 61 |
62 Table withAllSelected() { | 62 Table withAllSelected() { |
63 return new Table._raw(suite, baseline, report, | 63 return new Table._raw( |
64 new Set<pb.Request>.from(suite.requests)); | 64 suite, baseline, report, new Set<pb.Request>.from(suite.requests)); |
65 } | 65 } |
66 | 66 |
67 Table withNoneSelected() { | 67 Table withNoneSelected() { |
68 return new Table._raw(suite, baseline, report, new Set<pb.Request>()); | 68 return new Table._raw(suite, baseline, report, new Set<pb.Request>()); |
69 } | 69 } |
70 | 70 |
71 Table withSelection(pb.Request request, bool selected) { | 71 Table withSelection(pb.Request request, bool selected) { |
72 var s = new Set<pb.Request>.from(selections); | 72 var s = new Set<pb.Request>.from(selections); |
73 if (selected) { | 73 if (selected) { |
74 s.add(request); | 74 s.add(request); |
(...skipping 21 matching lines...) Expand all Loading... |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 // Indicates that the given item was added or removed from a selection. | 99 // Indicates that the given item was added or removed from a selection. |
100 class SelectEvent<T> { | 100 class SelectEvent<T> { |
101 final bool selected; | 101 final bool selected; |
102 final T item; | 102 final T item; |
103 SelectEvent(this.selected, [this.item]); | 103 SelectEvent(this.selected, [this.item]); |
104 toString() => "SelectEvent($selected, $item)"; | 104 toString() => "SelectEvent($selected, $item)"; |
105 } | 105 } |
OLD | NEW |