| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.utilities.general; | 4 library engine.utilities.general; |
| 5 | 5 |
| 6 import 'java_core.dart'; | |
| 7 | |
| 8 /** | 6 /** |
| 9 * Helper for measuring how much time is spent doing some operation. | 7 * Helper for measuring how much time is spent doing some operation. |
| 10 */ | 8 */ |
| 11 class TimeCounter { | 9 class TimeCounter { |
| 12 int _result = 0; | 10 Stopwatch _sw = new Stopwatch(); |
| 13 | 11 |
| 14 /** | 12 /** |
| 15 * @return the number of milliseconds spent between [start] and [stop]. | 13 * @return the number of milliseconds spent between [start] and [stop]. |
| 16 */ | 14 */ |
| 17 int get result => _result; | 15 int get result => _sw.elapsedMilliseconds; |
| 18 | 16 |
| 19 /** | 17 /** |
| 20 * Starts counting time. | 18 * Starts counting time. |
| 21 * | 19 * |
| 22 * @return the [TimeCounterHandle] that should be used to stop counting. | 20 * @return the [TimeCounterHandle] that should be used to stop counting. |
| 23 */ | 21 */ |
| 24 TimeCounter_TimeCounterHandle start() => new TimeCounter_TimeCounterHandle(thi
s); | 22 TimeCounter_TimeCounterHandle start() => new TimeCounter_TimeCounterHandle(thi
s); |
| 25 } | 23 } |
| 26 | 24 |
| 27 /** | 25 /** |
| 28 * The handle object that should be used to stop and update counter. | 26 * The handle object that should be used to stop and update counter. |
| 29 */ | 27 */ |
| 30 class TimeCounter_TimeCounterHandle { | 28 class TimeCounter_TimeCounterHandle { |
| 31 final TimeCounter TimeCounter_this; | 29 final TimeCounter _counter; |
| 32 | 30 |
| 33 int _startTime = JavaSystem.currentTimeMillis(); | 31 TimeCounter_TimeCounterHandle(this._counter) { |
| 34 | 32 _counter._sw.start(); |
| 35 TimeCounter_TimeCounterHandle(this.TimeCounter_this); | 33 } |
| 36 | 34 |
| 37 /** | 35 /** |
| 38 * Stops counting time and updates counter. | 36 * Stops counting time and updates counter. |
| 39 */ | 37 */ |
| 40 void stop() { | 38 void stop() { |
| 41 { | 39 _counter._sw.stop(); |
| 42 TimeCounter_this._result += JavaSystem.currentTimeMillis() - _startTime; | |
| 43 } | |
| 44 } | 40 } |
| 45 } | 41 } |
| OLD | NEW |