OLD | NEW |
1 part of dart.core; | 1 part of dart.core; |
2 class Stopwatch {int get frequency => _frequency; | 2 class Stopwatch {int get frequency => _frequency; |
3 num _start; | 3 num _start; |
4 num _stop; | 4 num _stop; |
5 Stopwatch() { | 5 Stopwatch() { |
6 _initTicker(); | 6 _initTicker(); |
7 } | 7 } |
8 void start() { | 8 void start() { |
9 if (isRunning) return; if (_start == null) { | 9 if (isRunning) return; if (_start == null) { |
10 _start = _now(); | 10 _start = _now(); |
11 } | 11 } |
12 else { | 12 else { |
13 _start = _now() - (_stop - _start); | 13 _start = _now() - (_stop - _start); |
14 _stop = null; | 14 _stop = null; |
15 } | 15 } |
16 } | 16 } |
17 void stop() { | 17 void stop() { |
18 if (!isRunning) return; _stop = _now(); | 18 if (!isRunning) return; _stop = _now(); |
19 } | 19 } |
20 void reset() { | 20 void reset() { |
21 if (_start == null) return; _start = _now(); | 21 if (_start == null) return; _start = _now(); |
22 if (_stop != null) { | 22 if (_stop != null) { |
23 _stop = _start; | 23 _stop = _start; |
24 } | 24 } |
25 } | 25 } |
26 int get elapsedTicks { | 26 int get elapsedTicks { |
27 if (_start == null) { | 27 if (_start == null) { |
28 return 0; | 28 return 0; |
29 } | 29 } |
30 return ((__x9) => DEVC$RT.cast(__x9, num, int, "ImplicitCast", """line 102, c
olumn 12 of dart:core/stopwatch.dart: """, __x9 is int, true))((_stop == null) ?
(_now() - _start) : (_stop - _start)); | 30 return ((__x20) => DEVC$RT.cast(__x20, num, int, "ImplicitCast", """line 102,
column 12 of dart:core/stopwatch.dart: """, __x20 is int, true))((_stop == null
) ? (_now() - _start) : (_stop - _start)); |
31 } | 31 } |
32 Duration get elapsed { | 32 Duration get elapsed { |
33 return new Duration(microseconds: elapsedMicroseconds); | 33 return new Duration(microseconds: elapsedMicroseconds); |
34 } | 34 } |
35 int get elapsedMicroseconds { | 35 int get elapsedMicroseconds { |
36 return (elapsedTicks * 1000000) ~/ frequency; | 36 return (elapsedTicks * 1000000) ~/ frequency; |
37 } | 37 } |
38 int get elapsedMilliseconds { | 38 int get elapsedMilliseconds { |
39 return (elapsedTicks * 1000) ~/ frequency; | 39 return (elapsedTicks * 1000) ~/ frequency; |
40 } | 40 } |
41 bool get isRunning => _start != null && _stop == null; | 41 bool get isRunning => _start != null && _stop == null; |
42 static int _frequency; | 42 static int _frequency; |
43 external static void _initTicker(); | 43 external static void _initTicker(); |
44 external static int _now(); | 44 external static int _now(); |
45 } | 45 } |
OLD | NEW |