| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 static final String spaces = " "; | 70 static final String spaces = " "; |
| 71 | 71 |
| 72 final String esc; | 72 final String esc; |
| 73 final String up; | 73 final String up; |
| 74 final String clear; | 74 final String clear; |
| 75 final int total; | 75 final int total; |
| 76 int ticks = 0; | 76 int ticks = 0; |
| 77 | 77 |
| 78 ProgressBar(int total) : this.escape(total, new String.fromCharCodes([27])); | 78 ProgressBar(int total) : this.escape(total, new String.fromCharCodes([27])); |
| 79 | 79 |
| 80 ProgressBar.escape(this.total, int esc) | 80 ProgressBar.escape(this.total, String esc) |
| 81 : esc = esc, up = "$esc[1A", clear = "$esc[K"; | 81 : esc = esc, up = "$esc[1A", clear = "$esc[K"; |
| 82 | 82 |
| 83 void begin() { | 83 void begin() { |
| 84 if (total > 10) { | 84 if (total > 10) { |
| 85 print("[$spaces] 0%"); | 85 print("[$spaces] 0%"); |
| 86 print("$up[${hashes.substring(0, ticks * spaces.length ~/ total)}"); | 86 print("$up[${hashes.substring(0, ticks * spaces.length ~/ total)}"); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void tick() { | 90 void tick() { |
| 91 if (total > 10 && ticks % 5 == 0) { | 91 if (total > 10 && ticks % 5 == 0) { |
| 92 print("$up$clear[$spaces] ${ticks * 100 ~/ total}%"); | 92 print("$up$clear[$spaces] ${ticks * 100 ~/ total}%"); |
| 93 print("$up[${hashes.substring(0, ticks * spaces.length ~/ total)}"); | 93 print("$up[${hashes.substring(0, ticks * spaces.length ~/ total)}"); |
| 94 } | 94 } |
| 95 ++ticks; | 95 ++ticks; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void end() { | 98 void end() { |
| 99 if (total > 10) { | 99 if (total > 10) { |
| 100 print("$up$clear[$hashes] 100%"); | 100 print("$up$clear[$hashes] 100%"); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 } | 103 } |
| OLD | NEW |