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

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

Issue 12389056: Add Duration.inMicroseconds and add Stopwatch.elapsed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
Index: sdk/lib/core/stopwatch.dart
diff --git a/sdk/lib/core/stopwatch.dart b/sdk/lib/core/stopwatch.dart
index 55648014c42149904c6829f3a8e3bfb9f8b02736..9afc50b37a264e74b715f63e686dfe4150f01155 100644
--- a/sdk/lib/core/stopwatch.dart
+++ b/sdk/lib/core/stopwatch.dart
@@ -20,16 +20,19 @@ class Stopwatch {
* Creates a [Stopwatch] in stopped state with a zero elapsed count.
*
* The following example shows how to start a [Stopwatch]
- * right after allocation.
+ * immediately after allocation.
*
* Stopwatch stopwatch = new Stopwatch()..start();
*/
Stopwatch() : _start = null, _stop = null {}
/**
- * Starts the [Stopwatch]. The [elapsed] count is increasing monotonically.
- * If the [Stopwatch] has been stopped, then calling start again restarts it
- * without resetting the [elapsed] count.
+ * Starts the [Stopwatch].
+ *
+ * The [elapsed] count is increasing monotonically. If the [Stopwatch] has
+ * been stopped, then calling start again restarts it without resetting the
+ * [elapsed] count.
+ *
* If the [Stopwatch] is currently running, then calling start does nothing.
*/
void start() {
@@ -46,9 +49,11 @@ class Stopwatch {
}
/**
- * Stops the [Stopwatch]. The [elapsed] count stops increasing.
- * If the [Stopwatch] is currently not running, then calling stop does
- * nothing.
+ * Stops the [Stopwatch].
+ *
+ * The [elapsedTicks] count stops increasing after this call. If the
+ * [Stopwatch] is currently not running, then calling this method has no
+ * effect.
*/
void stop() {
if (!isRunning) return;
@@ -56,8 +61,9 @@ class Stopwatch {
}
/**
- * Resets the [elapsed] count to zero. This method does not stop or start
- * the [Stopwatch].
+ * Resets the [elapsed] count to zero.
+ *
+ * This method does not stop or start the [Stopwatch].
*/
void reset() {
if (_start == null) return;
@@ -74,9 +80,12 @@ class Stopwatch {
/**
* Returns the elapsed number of clock ticks since calling [start] while the
* [Stopwatch] is running.
+ *
* Returns the elapsed number of clock ticks between calling [start] and
* calling [stop].
+ *
* Returns 0 if the [Stopwatch] has never been started.
+ *
* The elapsed number of clock ticks increases by [frequency] every second.
*/
int get elapsedTicks {
@@ -87,6 +96,13 @@ class Stopwatch {
}
/**
+ * Returns the [elapsedTicks] counter converted to a [Duration].
+ */
+ Duration get elapsed {
+ return new Duration(microseconds: elapsedMicroseconds);
+ }
+
+ /**
* Returns the [elapsedTicks] counter converted to microseconds.
*/
int get elapsedMicroseconds {

Powered by Google App Engine
This is Rietveld 408576698