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

Unified Diff: runtime/observatory/lib/utils.dart

Issue 965593002: Improved profiler view and inclusive profile tree (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/utils.dart
diff --git a/runtime/observatory/lib/utils.dart b/runtime/observatory/lib/utils.dart
index 58d18aaf1563870b7f7396d7f1b88df18f6e9aaa..522a11edda9893b00eda8977395cf00c9803f92e 100644
--- a/runtime/observatory/lib/utils.dart
+++ b/runtime/observatory/lib/utils.dart
@@ -7,11 +7,16 @@ library utils;
import 'dart:math';
class Utils {
- static String formatPercent(num a, num total) {
- var percent = 100.0 * (a / total);
+
+ static String formatPercentNormalized(double x) {
+ var percent = 100.0 * x;
return '${percent.toStringAsFixed(2)}%';
}
+ static String formatPercent(num a, num total) {
+ return formatPercentNormalized(a / total);
+ }
+
static String zeroPad(int value, int pad) {
String prefix = "";
while (pad > 1) {
@@ -47,11 +52,16 @@ class Utils {
if (time == null) {
return "-";
}
- const millisPerHour = 60 * 60 * 1000;
- const millisPerMinute = 60 * 1000;
const millisPerSecond = 1000;
var millis = (time * millisPerSecond).round();
+ return formatTimeMilliseconds(millis);
+ }
+
+ static String formatTimeMilliseconds(int millis) {
+ const millisPerHour = 60 * 60 * 1000;
+ const millisPerMinute = 60 * 1000;
+ const millisPerSecond = 1000;
var hours = millis ~/ millisPerHour;
millis = millis % millisPerHour;
@@ -64,12 +74,15 @@ class Utils {
if (hours > 0) {
return ("${zeroPad(hours,2)}"
- ":${zeroPad(minutes,2)}"
+ ":${zeroPad(minutes,2)}"
+ ":${zeroPad(seconds,2)}"
+ ".${zeroPad(millis,3)}");
+ } else if (minutes > 0) {
+ return ("${zeroPad(minutes,2)}"
":${zeroPad(seconds,2)}"
".${zeroPad(millis,3)}");
} else {
- return ("${zeroPad(minutes,2)}"
- ":${zeroPad(seconds,2)}"
+ return ("${zeroPad(seconds,2)}"
".${zeroPad(millis,3)}");
}
}
@@ -126,4 +139,4 @@ class Utils {
}
static bool runningInJavaScript() => identical(1.0, 1);
-}
+}
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698