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

Side by Side Diff: runtime/observatory/lib/utils.dart

Issue 2255613002: Converted Observatory heap-profile element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Better sorting tests Created 4 years, 4 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
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 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:math'; 8 import 'dart:math';
9 9
10 class Utils { 10 class Utils {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return '${now.year}-${now.month}-${now.day} ' 139 return '${now.year}-${now.month}-${now.day} '
140 '${now.hour.toString().padLeft(2)}:' 140 '${now.hour.toString().padLeft(2)}:'
141 '${now.minute.toString().padLeft(2)}:' 141 '${now.minute.toString().padLeft(2)}:'
142 '${now.second.toString().padLeft(2)}'; 142 '${now.second.toString().padLeft(2)}';
143 } 143 }
144 144
145 static String formatSeconds(double x) { 145 static String formatSeconds(double x) {
146 return x.toStringAsFixed(2); 146 return x.toStringAsFixed(2);
147 } 147 }
148 148
149 static String formatDurationInSeconds(Duration x) { 149 static String formatMillis(double x) {
150 return formatSeconds(x.inMilliseconds / Duration.MILLISECONDS_PER_SECOND); 150 return x.toStringAsFixed(2);
151 } 151 }
152 152
153 static String formatDurationInSeconds(Duration x) =>
154 formatSeconds(x.inMicroseconds / Duration.MICROSECONDS_PER_SECOND);
155
156 static String formatDurationInMilliseconds(Duration x) =>
157 formatMillis(x.inMicroseconds / Duration.MICROSECONDS_PER_MILLISECOND);
158
153 static bool runningInJavaScript() => identical(1.0, 1); 159 static bool runningInJavaScript() => identical(1.0, 1);
154 } 160 }
155 161
156 /// A [Task] that can be scheduled on the Dart event queue. 162 /// A [Task] that can be scheduled on the Dart event queue.
157 class Task { 163 class Task {
158 Timer _timer; 164 Timer _timer;
159 final Function callback; 165 final Function callback;
160 166
161 Task(this.callback); 167 Task(this.callback);
162 168
163 /// Queue [this] to run on the next Dart event queue pump. Does nothing 169 /// Queue [this] to run on the next Dart event queue pump. Does nothing
164 /// if [this] is already queued. 170 /// if [this] is already queued.
165 queue() { 171 queue() {
166 if (_timer != null) { 172 if (_timer != null) {
167 // Already scheduled. 173 // Already scheduled.
168 return; 174 return;
169 } 175 }
170 _timer = new Timer(Duration.ZERO, () { 176 _timer = new Timer(Duration.ZERO, () {
171 _timer = null; 177 _timer = null;
172 callback(); 178 callback();
173 }); 179 });
174 } 180 }
175 } 181 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/observatory/observatory_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698