Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Unified Diff: sdk/lib/core/stopwatch.dart

Issue 345873003: Update timer and adjust frequency. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cache stopwatch work. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « sdk/lib/_internal/lib/js_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698