Chromium Code Reviews| Index: sdk/lib/core/stopwatch.dart |
| diff --git a/sdk/lib/core/stopwatch.dart b/sdk/lib/core/stopwatch.dart |
| index 9650a570bc2c32a771f387c788ad5d0f2f0d2677..e923083a7d174b7d6e611bec9562be51f6579684 100644 |
| --- a/sdk/lib/core/stopwatch.dart |
| +++ b/sdk/lib/core/stopwatch.dart |
| @@ -11,7 +11,7 @@ class Stopwatch { |
| /** |
| * Frequency of the elapsed counter in Hz. |
| */ |
| - final int frequency = _frequency(); |
| + int get frequency => _frequency; |
|
Lasse Reichstein Nielsen
2014/06/20 23:29:52
Perhaps make this one external, so you don't need
floitsch
2014/06/23 08:54:26
_frequency is a static field.
|
| // The _start and _stop fields capture the time when [start] and [stop] |
| // are called respectively. |
| @@ -29,7 +29,9 @@ class Stopwatch { |
| * |
| * Stopwatch stopwatch = new Stopwatch()..start(); |
| */ |
| - Stopwatch(); |
| + Stopwatch() { |
| + _initTicker(); |
| + } |
| /** |
| * Starts the [Stopwatch]. |
| @@ -127,6 +129,15 @@ class Stopwatch { |
| */ |
| bool get isRunning => _start != null && _stop == null; |
| - external static int _frequency(); |
| + /** |
| + * Cached frequency of the system. Must be initialized in [_initTicker]; |
| + */ |
| + static int _frequency; |
| + |
| + /** |
| + * Initializes the time-measuring system. *Must* initialize the [_frequency] |
| + * variable. |
| + */ |
| + external static void _initTicker(); |
| external static int _now(); |
| } |