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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * A simple stopwatch interface to measure elapsed time. | 8 * A simple stopwatch interface to measure elapsed time. |
9 */ | 9 */ |
10 class Stopwatch { | 10 class Stopwatch { |
11 /** | 11 /** |
12 * Cached frequency of the system. Must be initialized in [_initTicker]; | 12 * Cached frequency of the system. Must be initialized in [_initTicker]; |
13 */ | 13 */ |
14 static int _frequency; | 14 static int _frequency; |
15 | 15 |
16 // The _start and _stop fields capture the time when [start] and [stop] | 16 // The _start and _stop fields capture the time when [start] and [stop] |
17 // are called respectively. | 17 // are called respectively. |
18 // If _stop is null, the stopwatched is running. | 18 // If _stop is null, the stopwatch is running. |
19 int _start = 0; | 19 int _start = 0; |
20 int _stop = 0; | 20 int _stop = 0; |
21 | 21 |
22 /** | 22 /** |
23 * Creates a [Stopwatch] in stopped state with a zero elapsed count. | 23 * Creates a [Stopwatch] in stopped state with a zero elapsed count. |
24 * | 24 * |
25 * The following example shows how to start a [Stopwatch] | 25 * The following example shows how to start a [Stopwatch] |
26 * immediately after allocation. | 26 * immediately after allocation. |
27 * ``` | 27 * ``` |
28 * var stopwatch = new Stopwatch()..start(); | 28 * var stopwatch = new Stopwatch()..start(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 */ | 117 */ |
118 bool get isRunning => _stop == null; | 118 bool get isRunning => _stop == null; |
119 | 119 |
120 /** | 120 /** |
121 * Initializes the time-measuring system. *Must* initialize the [_frequency] | 121 * Initializes the time-measuring system. *Must* initialize the [_frequency] |
122 * variable. | 122 * variable. |
123 */ | 123 */ |
124 external static void _initTicker(); | 124 external static void _initTicker(); |
125 external static int _now(); | 125 external static int _now(); |
126 } | 126 } |
OLD | NEW |