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); |
-} |
+} |