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

Side by Side Diff: pkg/analyzer/lib/src/generated/utilities_general.dart

Issue 263913003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.utilities.general; 8 library engine.utilities.general;
9 9
10 /** 10 /**
11 * Helper for measuring how much time is spent doing some operation. 11 * Helper for measuring how much time is spent doing some operation.
12 */ 12 */
13 class TimeCounter { 13 class TimeCounter {
14 static final int NANOS_PER_MILLI = 1000 * 1000;
15 static final int NANOS_PER_MICRO = 1000;
14 static TimeCounter _current = null; 16 static TimeCounter _current = null;
15 final Stopwatch _sw = new Stopwatch(); 17 final Stopwatch _sw = new Stopwatch();
16 18
17 /** 19 /**
18 * @return the number of milliseconds spent between [start] and [stop]. 20 * @return the number of milliseconds spent between [start] and [stop].
19 */ 21 */
20 int get result => _sw.elapsedMilliseconds; 22 int get result => _sw.elapsedMilliseconds;
21 23
22 /** 24 /**
23 * Starts counting time. 25 * Starts counting time.
24 * 26 *
25 * @return the [TimeCounterHandle] that should be used to stop counting. 27 * @return the [TimeCounterHandle] that should be used to stop counting.
26 */ 28 */
27 TimeCounter_TimeCounterHandle start() { 29 TimeCounter_TimeCounterHandle start() {
28 return new TimeCounter_TimeCounterHandle(this); 30 return new TimeCounter_TimeCounterHandle(this);
29 } 31 }
30 } 32 }
31 33
32 /** 34 /**
33 * The handle object that should be used to stop and update counter. 35 * The handle object that should be used to stop and update counter.
34 */ 36 */
35 class TimeCounter_TimeCounterHandle { 37 class TimeCounter_TimeCounterHandle {
36 final TimeCounter _counter; 38 final TimeCounter _counter;
39 int _startMicros;
37 TimeCounter _prev; 40 TimeCounter _prev;
38 41
39 TimeCounter_TimeCounterHandle(this._counter) { 42 TimeCounter_TimeCounterHandle(this._counter) {
40 // if there is some counter running, pause it 43 // if there is some counter running, pause it
41 _prev = TimeCounter._current; 44 _prev = TimeCounter._current;
42 if (_prev != null) { 45 if (_prev != null) {
43 _prev._sw.stop(); 46 _prev._sw.stop();
44 } 47 }
45 TimeCounter._current = _counter; 48 TimeCounter._current = _counter;
46 // start this counter 49 // start this counter
50 _startMicros = _counter._sw.elapsedMicroseconds;
47 _counter._sw.start(); 51 _counter._sw.start();
48 } 52 }
49 53
50 /** 54 /**
51 * Stops counting time and updates counter. 55 * Stops counting time and updates counter.
52 */ 56 */
53 void stop() { 57 int stop() {
54 _counter._sw.stop(); 58 _counter._sw.stop();
59 int elapsed = (_counter._sw.elapsedMicroseconds - _startMicros) *
60 TimeCounter.NANOS_PER_MICRO;
55 // restore previous counter and resume it 61 // restore previous counter and resume it
56 TimeCounter._current = _prev; 62 TimeCounter._current = _prev;
57 if (_prev != null) { 63 if (_prev != null) {
58 _prev._sw.start(); 64 _prev._sw.start();
59 } 65 }
66 // done
67 return elapsed;
60 } 68 }
61 } 69 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source_io.dart ('k') | pkg/analyzer/lib/src/services/formatter_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698