Version 2.12.0-173.0.dev
Merge commit '7e3b19e11113d60d5cded0623c699d98e487c86d' into 'dev'
diff --git a/runtime/observatory/lib/utils.dart b/runtime/observatory/lib/utils.dart
index 940a6e1..a23dc64 100644
--- a/runtime/observatory/lib/utils.dart
+++ b/runtime/observatory/lib/utils.dart
@@ -98,24 +98,25 @@
static String formatSize(bytesDynamic) {
int bytes = bytesDynamic.toInt();
- int absBytes = bytes >= 0 ? bytes : -bytes;
- const int digits = 1;
+
+ String finish(int scale, String prefix) {
+ double scaled = bytes / scale;
+ int digits = 1;
+ if (scaled < 10) digits = 2;
+ return "${scaled.toStringAsFixed(digits)}${prefix}B";
+ }
+
const int bytesPerKB = 1024;
const int bytesPerMB = 1024 * bytesPerKB;
const int bytesPerGB = 1024 * bytesPerMB;
const int bytesPerTB = 1024 * bytesPerGB;
- if (absBytes < bytesPerKB) {
- return "${bytes}B";
- } else if (absBytes < bytesPerMB) {
- return "${(bytes / bytesPerKB).toStringAsFixed(digits)}KB";
- } else if (absBytes < bytesPerGB) {
- return "${(bytes / bytesPerMB).toStringAsFixed(digits)}MB";
- } else if (absBytes < bytesPerTB) {
- return "${(bytes / bytesPerGB).toStringAsFixed(digits)}GB";
- } else {
- return "${(bytes / bytesPerTB).toStringAsFixed(digits)}TB";
- }
+ int absBytes = bytes >= 0 ? bytes : -bytes;
+ if (absBytes < bytesPerKB) return "${bytes}B";
+ if (absBytes < bytesPerMB) return finish(bytesPerKB, "K");
+ if (absBytes < bytesPerGB) return finish(bytesPerMB, "M");
+ if (absBytes < bytesPerTB) return finish(bytesPerGB, "G");
+ return finish(bytesPerTB, "TB");
}
static String formatTime(double time) {
diff --git a/tools/VERSION b/tools/VERSION
index 7c96765..fd18663 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 12
PATCH 0
-PRERELEASE 172
+PRERELEASE 173
PRERELEASE_PATCH 0
\ No newline at end of file