| 414 | constexpr unsigned long long ExpTo1024(unsigned n) { return 1ULL << (n * 10); } |
| 415 | |
| 416 | std::string BytesToHuman(uint64_t n) { |
| 417 | if (n < ExpTo1024(1)) { |
| 418 | return fmt::format("{}B", n); |
| 419 | } else if (n < ExpTo1024(2)) { |
| 420 | return fmt::format("{:.2f}K", static_cast<double>(n) / ExpTo1024(1)); |
| 421 | } else if (n < ExpTo1024(3)) { |
| 422 | return fmt::format("{:.2f}M", static_cast<double>(n) / ExpTo1024(2)); |
| 423 | } else if (n < ExpTo1024(4)) { |
| 424 | return fmt::format("{:.2f}G", static_cast<double>(n) / ExpTo1024(3)); |
| 425 | } else if (n < ExpTo1024(5)) { |
| 426 | return fmt::format("{:.2f}T", static_cast<double>(n) / ExpTo1024(4)); |
| 427 | } else if (n < ExpTo1024(6)) { |
| 428 | return fmt::format("{:.2f}P", static_cast<double>(n) / ExpTo1024(5)); |
| 429 | } else { |
| 430 | return fmt::format("{}B", n); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | std::vector<std::string> TokenizeRedisProtocol(const std::string &value) { |
| 435 | std::vector<std::string> tokens; |
no test coverage detected