MCPcopy Create free account
hub / github.com/Tencent/Tendis / getSizeReadable

Function getSizeReadable

src/tendisplus/utils/string.cpp:445–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445std::string getSizeReadable(size_t size) {
446 char buf[20];
447 double KB = 1024;
448 double MB = 1024 * 1024;
449 double GB = 1024 * 1024 * 1024;
450 if (size < KB) {
451 return std::to_string(size) + " B";
452 } else if (size < MB) {
453 snprintf(buf, sizeof(buf), "%.3f KB", size / KB);
454 return buf;
455 } else if (size < GB) {
456 snprintf(buf, sizeof(buf), "%.3f MB", size / MB);
457 return buf;
458 } else {
459 snprintf(buf, sizeof(buf), "%.3f GB", size / GB);
460 return buf;
461 }
462}
463
464std::string getTimeReadable(size_t ns) {
465 char buf[20];

Callers 1

getUsageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected