OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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('scanner_bench'); | 5 #library('scanner_bench'); |
6 #import('scannerlib.dart'); | 6 #import('scannerlib.dart'); |
7 #import('scanner_implementation.dart'); | 7 #import('scanner_implementation.dart'); |
8 #source('source_list.dart'); | 8 #source('source_list.dart'); |
9 | 9 |
10 /** | 10 /** |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 ++ticks; | 105 ++ticks; |
106 } | 106 } |
107 | 107 |
108 void end() { | 108 void end() { |
109 if (total > 10) { | 109 if (total > 10) { |
110 print("$up$clear[$hashes] 100% ${score()}"); | 110 print("$up$clear[$hashes] 100% ${score()}"); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 void recordScore(num score) { | 114 void recordScore(num newScore) { |
115 scores.addLast(score); | 115 scores.addLast(newScore); |
116 } | 116 } |
117 | 117 |
118 int score() { | 118 int score() { |
119 num geoMean = 1; | 119 num geoMean = 1; |
120 int count = Math.min(scores.length, GEOMEAN_COUNT); | 120 int count = Math.min(scores.length, GEOMEAN_COUNT); |
121 for (int i = scores.length - count; i < scores.length; i++) { | 121 for (int i = scores.length - count; i < scores.length; i++) { |
122 geoMean *= scores[i]; | 122 geoMean *= scores[i]; |
123 } | 123 } |
124 geoMean = Math.pow(geoMean, 1/Math.max(count, 1)); | 124 geoMean = Math.pow(geoMean, 1/Math.max(count, 1)); |
125 return geoMean.round().toInt(); | 125 return geoMean.round().toInt(); |
(...skipping 15 matching lines...) Expand all Loading... |
141 | 141 |
142 void end() { | 142 void end() { |
143 } | 143 } |
144 | 144 |
145 void recordScore(num score) { | 145 void recordScore(num score) { |
146 if (total > 10) { | 146 if (total > 10) { |
147 print("$ticks, $score, ${ticks * 100 ~/ total}%"); | 147 print("$ticks, $score, ${ticks * 100 ~/ total}%"); |
148 } | 148 } |
149 } | 149 } |
150 } | 150 } |
OLD | NEW |