| 433 | } |
| 434 | |
| 435 | string HumanReadableNum(int64 value) { |
| 436 | string s; |
| 437 | if (value < 0) { |
| 438 | s += "-"; |
| 439 | value = -value; |
| 440 | } |
| 441 | if (value < 1000) { |
| 442 | Appendf(&s, "%lld", value); |
| 443 | } else if (value >= static_cast<int64>(1e15)) { |
| 444 | // Number bigger than 1E15; use that notation. |
| 445 | Appendf(&s, "%0.3G", static_cast<double>(value)); |
| 446 | } else { |
| 447 | static const char units[] = "kMBT"; |
| 448 | const char* unit = units; |
| 449 | while (value >= static_cast<int64>(1000000)) { |
| 450 | value /= static_cast<int64>(1000); |
| 451 | ++unit; |
| 452 | CHECK(unit < units + TF_ARRAYSIZE(units)); |
| 453 | } |
| 454 | Appendf(&s, "%.2f%c", value / 1000.0, *unit); |
| 455 | } |
| 456 | return s; |
| 457 | } |
| 458 | |
| 459 | string HumanReadableNumBytes(int64 num_bytes) { |
| 460 | if (num_bytes == kint64min) { |