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

Side by Side Diff: pkg/fasta/lib/src/ticker.dart

Issue 2634453004: Fasta infrastructure. (Closed)
Patch Set: Address review comments. Created 3 years, 11 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
« no previous file with comments | « pkg/fasta/lib/src/target_implementation.dart ('k') | pkg/fasta/lib/src/translate_uri.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 library fasta.ticker;
6
7 class Ticker {
8 final Stopwatch sw = new Stopwatch()..start();
9
10 bool isVerbose;
11
12 Duration previousTick;
13
14 Ticker({this.isVerbose: true}) {
15 previousTick = sw.elapsed;
16 }
17
18 void logMs(Object message) {
19 log((Duration elapsed, Duration sinceStart) {
20 print("$sinceStart: $message in ${elapsed.inMilliseconds}ms.");
21 });
22 }
23
24 void log(void f(Duration elapsed, Duration sinceStart)) {
25 Duration elapsed = sw.elapsed;
26 try {
27 if (isVerbose) f(elapsed - previousTick, elapsed);
28 } finally {
29 previousTick = sw.elapsed;
30 }
31 }
32 }
OLDNEW
« no previous file with comments | « pkg/fasta/lib/src/target_implementation.dart ('k') | pkg/fasta/lib/src/translate_uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698