From cad6bf99af345ddc4708e667526655d49fffbadb Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Tue, 15 Sep 2020 13:01:46 -0400 Subject: [PATCH 1/4] Add padding to remove previous line's leftovers, and keep the printed line to around the same size --- programs/fileio.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index b27f314ad..86ce997d1 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1338,14 +1338,23 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx, cShare ); } else { /* summarized notifications if == 2 */ if (fCtx->nbFilesTotal > 1) { - DISPLAYLEVEL(2, "\rCompressing %u/%u files. Current source: %s ", fCtx->currFileIdx+1, fCtx->nbFilesTotal, srcFileName); + size_t srcFileNameSize = strlen(srcFileName); + /* Ensure that the string we print is roughly the same size each time */ + if (srcFileNameSize > 20) { + const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 17; + DISPLAYLEVEL(2, "\rCompressing %2u / %2u files. Current source: ...%s ", + fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName); + } else { + DISPLAYLEVEL(2, "\rCompressing %2u / %2u files. Current source: %*s ", + fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(20-srcFileNameSize), srcFileName); + } } else { DISPLAYLEVEL(2, "\r"); } - DISPLAYLEVEL(2, "Read : %u ", (unsigned)(zfp.consumed >> 20)); + DISPLAYLEVEL(2, "Read : %2u ", (unsigned)(zfp.consumed >> 20)); if (fileSize != UTIL_FILESIZE_UNKNOWN) - DISPLAYLEVEL(2, "/ %u ", (unsigned)(fileSize >> 20)); - DISPLAYLEVEL(2, "MB ==> %2.f%%", cShare); + DISPLAYLEVEL(2, "/ %2u ", (unsigned)(fileSize >> 20)); + DISPLAYLEVEL(2, "MB ==> %2.f%% ", cShare); DELAY_NEXT_UPDATE(); } @@ -1817,9 +1826,9 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx, } if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0) - DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu bytes)\n", fCtx->nbFilesProcessed, + DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu %-40s\n", fCtx->nbFilesProcessed, (double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100, - fCtx->totalBytesInput, fCtx->totalBytesOutput); + fCtx->totalBytesInput, fCtx->totalBytesOutput, "bytes)"); FIO_freeCResources(ress); return error; From ab0d332563ee86e3711b28dbae8ca536e4f6b533 Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Tue, 15 Sep 2020 15:53:32 -0400 Subject: [PATCH 2/4] Add display clears --- programs/fileio.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 86ce997d1..a183186b7 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1337,24 +1337,23 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx, (unsigned)(zfp.produced >> 20), cShare ); } else { /* summarized notifications if == 2 */ + DISPLAYLEVEL(2, "\r%79s\r", ""); /* Clear out the current displayed line */ if (fCtx->nbFilesTotal > 1) { size_t srcFileNameSize = strlen(srcFileName); /* Ensure that the string we print is roughly the same size each time */ - if (srcFileNameSize > 20) { - const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 17; - DISPLAYLEVEL(2, "\rCompressing %2u / %2u files. Current source: ...%s ", + if (srcFileNameSize > 18) { + const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 15; + DISPLAYLEVEL(2, "Compress: %2u/%2u files. Current: ...%s ", fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName); } else { - DISPLAYLEVEL(2, "\rCompressing %2u / %2u files. Current source: %*s ", - fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(20-srcFileNameSize), srcFileName); + DISPLAYLEVEL(2, "Compress: %2u/%2u files. Current: %*s ", + fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(18-srcFileNameSize), srcFileName); } - } else { - DISPLAYLEVEL(2, "\r"); } DISPLAYLEVEL(2, "Read : %2u ", (unsigned)(zfp.consumed >> 20)); if (fileSize != UTIL_FILESIZE_UNKNOWN) DISPLAYLEVEL(2, "/ %2u ", (unsigned)(fileSize >> 20)); - DISPLAYLEVEL(2, "MB ==> %2.f%% ", cShare); + DISPLAYLEVEL(2, "MB ==> %2.f%%", cShare); DELAY_NEXT_UPDATE(); } @@ -1825,10 +1824,12 @@ int FIO_compressMultipleFilenames(FIO_ctx_t* const fCtx, FIO_checkFilenameCollisions(inFileNamesTable , fCtx->nbFilesTotal); } - if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0) - DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu %-40s\n", fCtx->nbFilesProcessed, + if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0) { + DISPLAYLEVEL(2, "\r%79s\r", ""); + DISPLAYLEVEL(2, "%d files compressed : %.2f%% (%6zu => %6zu bytes)\n", fCtx->nbFilesProcessed, (double)fCtx->totalBytesOutput/((double)fCtx->totalBytesInput)*100, - fCtx->totalBytesInput, fCtx->totalBytesOutput, "bytes)"); + fCtx->totalBytesInput, fCtx->totalBytesOutput); + } FIO_freeCResources(ress); return error; @@ -2100,7 +2101,7 @@ FIO_decompressZstdFrame(FIO_ctx_t* const fCtx, dRess_t* ress, FILE* finput, storedSkips = FIO_fwriteSparse(ress->dstFile, ress->dstBuffer, outBuff.pos, prefs, storedSkips); frameSize += outBuff.pos; if (fCtx->nbFilesTotal > 1) { - DISPLAYUPDATE(2, "\rDecompressing %u/%u files. Current source: %-20.20s : %u MB... ", + DISPLAYUPDATE(2, "\rDecompress: %u/%u files. Current source: %-20.20s : %u MB... ", fCtx->currFileIdx+1, fCtx->nbFilesTotal, srcFileName, (unsigned)((alreadyDecoded+frameSize)>>20) ); } else { DISPLAYUPDATE(2, "\r%-20.20s : %u MB... ", From 1d5c6fda9f99d77ed3aab105c4a7abf7aad13b4a Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Wed, 16 Sep 2020 10:28:45 -0400 Subject: [PATCH 3/4] Add filename truncations to decompression --- programs/fileio.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index a183186b7..9fb618e55 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -1343,10 +1343,10 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx, /* Ensure that the string we print is roughly the same size each time */ if (srcFileNameSize > 18) { const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 15; - DISPLAYLEVEL(2, "Compress: %2u/%2u files. Current: ...%s ", + DISPLAYLEVEL(2, "Compress: %u/%u files. Current: ...%s ", fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName); } else { - DISPLAYLEVEL(2, "Compress: %2u/%2u files. Current: %*s ", + DISPLAYLEVEL(2, "Compress: %u/%u files. Current: %*s ", fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(18-srcFileNameSize), srcFileName); } } @@ -2101,8 +2101,15 @@ FIO_decompressZstdFrame(FIO_ctx_t* const fCtx, dRess_t* ress, FILE* finput, storedSkips = FIO_fwriteSparse(ress->dstFile, ress->dstBuffer, outBuff.pos, prefs, storedSkips); frameSize += outBuff.pos; if (fCtx->nbFilesTotal > 1) { - DISPLAYUPDATE(2, "\rDecompress: %u/%u files. Current source: %-20.20s : %u MB... ", - fCtx->currFileIdx+1, fCtx->nbFilesTotal, srcFileName, (unsigned)((alreadyDecoded+frameSize)>>20) ); + size_t srcFileNameSize = strlen(srcFileName); + if (srcFileNameSize > 18) { + const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 15; + DISPLAYUPDATE(2, "\rDecompress: %2u/%2u files. Current: ...%s : %u MB... ", + fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName, (unsigned)((alreadyDecoded+frameSize)>>20) ); + } else { + DISPLAYUPDATE(2, "\rDecompress: %2u/%2u files. Current: %s : %u MB... ", + fCtx->currFileIdx+1, fCtx->nbFilesTotal, srcFileName, (unsigned)((alreadyDecoded+frameSize)>>20) ); + } } else { DISPLAYUPDATE(2, "\r%-20.20s : %u MB... ", srcFileName, (unsigned)((alreadyDecoded+frameSize)>>20) ); From 29b8f2eb0844d36503d39fa0ba7a028b4d68280b Mon Sep 17 00:00:00 2001 From: senhuang42 Date: Wed, 16 Sep 2020 10:38:13 -0400 Subject: [PATCH 4/4] Fix multifile decompression summary --- programs/fileio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/fileio.c b/programs/fileio.c index 9fb618e55..243d26ada 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -2743,7 +2743,7 @@ FIO_decompressMultipleFilenames(FIO_ctx_t* const fCtx, FIO_checkFilenameCollisions(srcNamesTable , fCtx->nbFilesTotal); } - if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesInput != 0) + if (fCtx->nbFilesProcessed >= 1 && fCtx->nbFilesTotal > 1 && fCtx->totalBytesOutput != 0) DISPLAYLEVEL(2, "%d files decompressed : %6zu bytes total \n", fCtx->nbFilesProcessed, fCtx->totalBytesOutput); FIO_freeDResources(ress);