1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

Change Suffix (e.g., "G" -> " GB")

This commit is contained in:
W. Felix Handte
2021-06-09 15:26:16 -04:00
parent 464bfb022e
commit 93bb368d74
2 changed files with 10 additions and 10 deletions

View File

@ -1898,7 +1898,7 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx,
UTIL_HumanReadableSize_t hr_osize = UTIL_makeHumanReadableSize((U64) fCtx->totalBytesOutput); UTIL_HumanReadableSize_t hr_osize = UTIL_makeHumanReadableSize((U64) fCtx->totalBytesOutput);
DISPLAYLEVEL(2, "\r%79s\r", ""); DISPLAYLEVEL(2, "\r%79s\r", "");
DISPLAYLEVEL(2, "%3d files compressed : %.2f%% (%.*f%s => %.*f%s bytes)\n", DISPLAYLEVEL(2, "%3d files compressed : %.2f%% (%.*f%s => %.*f%s)\n",
fCtx->nbFilesProcessed, fCtx->nbFilesProcessed,
(double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100, (double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100,
hr_isize.precision, hr_isize.value, hr_isize.suffix, hr_isize.precision, hr_isize.value, hr_isize.suffix,

View File

@ -311,38 +311,38 @@ UTIL_HumanReadableSize_t UTIL_makeHumanReadableSize(U64 size) {
* values that exceed the integral precision of a double. */ * values that exceed the integral precision of a double. */
if (size >= (1ull << 53)) { if (size >= (1ull << 53)) {
hrs.value = (double)size / (1ull << 20); hrs.value = (double)size / (1ull << 20);
hrs.suffix = "M"; hrs.suffix = " MB";
/* At worst, a double representation of a maximal size will be /* At worst, a double representation of a maximal size will be
* accurate to better than tens of kilobytes. */ * accurate to better than tens of kilobytes. */
hrs.precision = 2; hrs.precision = 2;
} else { } else {
hrs.value = (double)size; hrs.value = (double)size;
hrs.suffix = ""; hrs.suffix = " B";
hrs.precision = 0; hrs.precision = 0;
} }
} else { } else {
/* In regular mode, scale sizes down and use suffixes. */ /* In regular mode, scale sizes down and use suffixes. */
if (size >= (1ull << 60)) { if (size >= (1ull << 60)) {
hrs.value = (double)size / (1ull << 60); hrs.value = (double)size / (1ull << 60);
hrs.suffix = "E"; hrs.suffix = " EB";
} else if (size >= (1ull << 50)) { } else if (size >= (1ull << 50)) {
hrs.value = (double)size / (1ull << 50); hrs.value = (double)size / (1ull << 50);
hrs.suffix = "P"; hrs.suffix = " PB";
} else if (size >= (1ull << 40)) { } else if (size >= (1ull << 40)) {
hrs.value = (double)size / (1ull << 40); hrs.value = (double)size / (1ull << 40);
hrs.suffix = "T"; hrs.suffix = " TB";
} else if (size >= (1ull << 30)) { } else if (size >= (1ull << 30)) {
hrs.value = (double)size / (1ull << 30); hrs.value = (double)size / (1ull << 30);
hrs.suffix = "G"; hrs.suffix = " GB";
} else if (size >= (1ull << 20)) { } else if (size >= (1ull << 20)) {
hrs.value = (double)size / (1ull << 20); hrs.value = (double)size / (1ull << 20);
hrs.suffix = "M"; hrs.suffix = " MB";
} else if (size >= (1ull << 10)) { } else if (size >= (1ull << 10)) {
hrs.value = (double)size / (1ull << 10); hrs.value = (double)size / (1ull << 10);
hrs.suffix = "K"; hrs.suffix = " KB";
} else { } else {
hrs.value = (double)size; hrs.value = (double)size;
hrs.suffix = ""; hrs.suffix = " B";
} }
if (hrs.value >= 100 || (U64)hrs.value == size) { if (hrs.value >= 100 || (U64)hrs.value == size) {