OLD | NEW |
| (Empty) |
1 part of dart.core; | |
2 class Stopwatch {int get frequency => _frequency; | |
3 num _start; | |
4 num _stop; | |
5 Stopwatch() { | |
6 _initTicker(); | |
7 } | |
8 void start() { | |
9 if (isRunning) return; if (_start == null) { | |
10 _start = _now(); | |
11 } | |
12 else { | |
13 _start = _now() - (_stop - _start); | |
14 _stop = null; | |
15 } | |
16 } | |
17 void stop() { | |
18 if (!isRunning) return; _stop = _now(); | |
19 } | |
20 void reset() { | |
21 if (_start == null) return; _start = _now(); | |
22 if (_stop != null) { | |
23 _stop = _start; | |
24 } | |
25 } | |
26 int get elapsedTicks { | |
27 if (_start == null) { | |
28 return 0; | |
29 } | |
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 } | |
32 Duration get elapsed { | |
33 return new Duration(microseconds: elapsedMicroseconds); | |
34 } | |
35 int get elapsedMicroseconds { | |
36 return (elapsedTicks * 1000000) ~/ frequency; | |
37 } | |
38 int get elapsedMilliseconds { | |
39 return (elapsedTicks * 1000) ~/ frequency; | |
40 } | |
41 bool get isRunning => _start != null && _stop == null; | |
42 static int _frequency; | |
43 external static void _initTicker(); | |
44 external static int _now(); | |
45 } | |
OLD | NEW |