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

Side by Side Diff: lib/coreimpl/stopwatch_implementation.dart

Issue 11265024: Make methods in Stopwatch getters and rename to be more consistent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/core/stopwatch.dart ('k') | tests/benchmark_smoke/benchmark_base.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A simple implementation of the [Stopwatch] interface. 6 * A simple implementation of the [Stopwatch] interface.
7 */ 7 */
8 class StopwatchImplementation implements Stopwatch { 8 class StopwatchImplementation implements Stopwatch {
9 // The _start and _stop fields capture the time when [start] and [stop] 9 // The _start and _stop fields capture the time when [start] and [stop]
10 // are called respectively. 10 // are called respectively.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // If [_start] is not null, then the stopwatch had already been started. It 43 // If [_start] is not null, then the stopwatch had already been started. It
44 // may running right now. 44 // may running right now.
45 _start = _now(); 45 _start = _now();
46 if (_stop !== null) { 46 if (_stop !== null) {
47 // The watch is not running. So simply set the [_stop] to [_start] thus 47 // The watch is not running. So simply set the [_stop] to [_start] thus
48 // having an elapsed time of 0. 48 // having an elapsed time of 0.
49 _stop = _start; 49 _stop = _start;
50 } 50 }
51 } 51 }
52 52
53 int elapsed() { 53 int get elapsedTicks {
54 if (_start === null) { 54 if (_start === null) {
55 return 0; 55 return 0;
56 } 56 }
57 return (_stop === null) ? (_now() - _start) : (_stop - _start); 57 return (_stop === null) ? (_now() - _start) : (_stop - _start);
58 } 58 }
59 59
60 int elapsedInUs() { 60 int get elapsedMicroseconds {
61 return (elapsed() * 1000000) ~/ frequency(); 61 return (elapsedTicks * 1000000) ~/ frequency;
62 } 62 }
63 63
64 int elapsedInMs() { 64 int get elapsedMilliseconds {
65 return (elapsed() * 1000) ~/ frequency(); 65 return (elapsedTicks * 1000) ~/ frequency;
66 } 66 }
67 67
68 int frequency() => _frequency(); 68 int get frequency => _frequency();
69 69
70 external static int _frequency(); 70 external static int _frequency();
71 external static int _now(); 71 external static int _now();
72 } 72 }
OLDNEW
« no previous file with comments | « lib/core/stopwatch.dart ('k') | tests/benchmark_smoke/benchmark_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698