Add --progress flag (#2595)
This commit is contained in:
+13
-12
@@ -93,10 +93,10 @@
|
|||||||
|
|
||||||
struct FIO_display_prefs_s {
|
struct FIO_display_prefs_s {
|
||||||
int displayLevel; /* 0 : no display; 1: errors; 2: + result + interaction + warnings; 3: + progression; 4: + information */
|
int displayLevel; /* 0 : no display; 1: errors; 2: + result + interaction + warnings; 3: + progression; 4: + information */
|
||||||
U32 noProgress;
|
FIO_progressSetting_e progressSetting;
|
||||||
};
|
};
|
||||||
|
|
||||||
static FIO_display_prefs_t g_display_prefs = {2, 0};
|
static FIO_display_prefs_t g_display_prefs = {2, FIO_ps_auto};
|
||||||
|
|
||||||
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||||
#define DISPLAYOUT(...) fprintf(stdout, __VA_ARGS__)
|
#define DISPLAYOUT(...) fprintf(stdout, __VA_ARGS__)
|
||||||
@@ -105,10 +105,10 @@ static FIO_display_prefs_t g_display_prefs = {2, 0};
|
|||||||
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
|
|
||||||
#define READY_FOR_UPDATE() (!g_display_prefs.noProgress && UTIL_clockSpanMicro(g_displayClock) > g_refreshRate)
|
#define READY_FOR_UPDATE() ((g_display_prefs.progressSetting != FIO_ps_never) && UTIL_clockSpanMicro(g_displayClock) > g_refreshRate)
|
||||||
#define DELAY_NEXT_UPDATE() { g_displayClock = UTIL_getTime(); }
|
#define DELAY_NEXT_UPDATE() { g_displayClock = UTIL_getTime(); }
|
||||||
#define DISPLAYUPDATE(l, ...) { \
|
#define DISPLAYUPDATE(l, ...) { \
|
||||||
if (g_display_prefs.displayLevel>=l && !g_display_prefs.noProgress) { \
|
if (g_display_prefs.displayLevel>=l && (g_display_prefs.progressSetting != FIO_ps_never)) { \
|
||||||
if (READY_FOR_UPDATE() || (g_display_prefs.displayLevel>=4)) { \
|
if (READY_FOR_UPDATE() || (g_display_prefs.displayLevel>=4)) { \
|
||||||
DELAY_NEXT_UPDATE(); \
|
DELAY_NEXT_UPDATE(); \
|
||||||
DISPLAY(__VA_ARGS__); \
|
DISPLAY(__VA_ARGS__); \
|
||||||
@@ -430,7 +430,7 @@ void FIO_freeContext(FIO_ctx_t* const fCtx)
|
|||||||
|
|
||||||
void FIO_setNotificationLevel(int level) { g_display_prefs.displayLevel=level; }
|
void FIO_setNotificationLevel(int level) { g_display_prefs.displayLevel=level; }
|
||||||
|
|
||||||
void FIO_setNoProgress(unsigned noProgress) { g_display_prefs.noProgress = noProgress; }
|
void FIO_setProgressSetting(FIO_progressSetting_e setting) { g_display_prefs.progressSetting = setting; }
|
||||||
|
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
@@ -1404,24 +1404,25 @@ FIO_compressZstdFrame(FIO_ctx_t* const fCtx,
|
|||||||
(unsigned)(zfp.consumed >> 20),
|
(unsigned)(zfp.consumed >> 20),
|
||||||
(unsigned)(zfp.produced >> 20),
|
(unsigned)(zfp.produced >> 20),
|
||||||
cShare );
|
cShare );
|
||||||
} else { /* summarized notifications if == 2 */
|
} else if (g_display_prefs.displayLevel >= 2 || g_display_prefs.progressSetting == FIO_ps_always) {
|
||||||
DISPLAYLEVEL(2, "\r%79s\r", ""); /* Clear out the current displayed line */
|
/* Require level 2 or forcibly displayed progress counter for summarized updates */
|
||||||
|
DISPLAYLEVEL(1, "\r%79s\r", ""); /* Clear out the current displayed line */
|
||||||
if (fCtx->nbFilesTotal > 1) {
|
if (fCtx->nbFilesTotal > 1) {
|
||||||
size_t srcFileNameSize = strlen(srcFileName);
|
size_t srcFileNameSize = strlen(srcFileName);
|
||||||
/* Ensure that the string we print is roughly the same size each time */
|
/* Ensure that the string we print is roughly the same size each time */
|
||||||
if (srcFileNameSize > 18) {
|
if (srcFileNameSize > 18) {
|
||||||
const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 15;
|
const char* truncatedSrcFileName = srcFileName + srcFileNameSize - 15;
|
||||||
DISPLAYLEVEL(2, "Compress: %u/%u files. Current: ...%s ",
|
DISPLAYLEVEL(1, "Compress: %u/%u files. Current: ...%s ",
|
||||||
fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName);
|
fCtx->currFileIdx+1, fCtx->nbFilesTotal, truncatedSrcFileName);
|
||||||
} else {
|
} else {
|
||||||
DISPLAYLEVEL(2, "Compress: %u/%u files. Current: %*s ",
|
DISPLAYLEVEL(1, "Compress: %u/%u files. Current: %*s ",
|
||||||
fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(18-srcFileNameSize), srcFileName);
|
fCtx->currFileIdx+1, fCtx->nbFilesTotal, (int)(18-srcFileNameSize), srcFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DISPLAYLEVEL(2, "Read : %2u ", (unsigned)(zfp.consumed >> 20));
|
DISPLAYLEVEL(1, "Read : %2u ", (unsigned)(zfp.consumed >> 20));
|
||||||
if (fileSize != UTIL_FILESIZE_UNKNOWN)
|
if (fileSize != UTIL_FILESIZE_UNKNOWN)
|
||||||
DISPLAYLEVEL(2, "/ %2u ", (unsigned)(fileSize >> 20));
|
DISPLAYLEVEL(2, "/ %2u ", (unsigned)(fileSize >> 20));
|
||||||
DISPLAYLEVEL(2, "MB ==> %2.f%%", cShare);
|
DISPLAYLEVEL(1, "MB ==> %2.f%%", cShare);
|
||||||
DELAY_NEXT_UPDATE();
|
DELAY_NEXT_UPDATE();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2164,7 +2165,7 @@ FIO_decompressZstdFrame(FIO_ctx_t* const fCtx, dRess_t* ress, FILE* finput,
|
|||||||
/* Write block */
|
/* Write block */
|
||||||
storedSkips = FIO_fwriteSparse(ress->dstFile, ress->dstBuffer, outBuff.pos, prefs, storedSkips);
|
storedSkips = FIO_fwriteSparse(ress->dstFile, ress->dstBuffer, outBuff.pos, prefs, storedSkips);
|
||||||
frameSize += outBuff.pos;
|
frameSize += outBuff.pos;
|
||||||
if (!fCtx->hasStdoutOutput) {
|
if (!fCtx->hasStdoutOutput || g_display_prefs.progressSetting == FIO_ps_always) {
|
||||||
if (fCtx->nbFilesTotal > 1) {
|
if (fCtx->nbFilesTotal > 1) {
|
||||||
size_t srcFileNameSize = strlen(srcFileName);
|
size_t srcFileNameSize = strlen(srcFileName);
|
||||||
if (srcFileNameSize > 18) {
|
if (srcFileNameSize > 18) {
|
||||||
|
|||||||
+3
-1
@@ -68,6 +68,8 @@ void FIO_freeContext(FIO_ctx_t* const fCtx);
|
|||||||
|
|
||||||
typedef struct FIO_display_prefs_s FIO_display_prefs_t;
|
typedef struct FIO_display_prefs_s FIO_display_prefs_t;
|
||||||
|
|
||||||
|
typedef enum { FIO_ps_auto, FIO_ps_never, FIO_ps_always } FIO_progressSetting_e;
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Parameters
|
* Parameters
|
||||||
***************************************/
|
***************************************/
|
||||||
@@ -100,7 +102,7 @@ void FIO_setLiteralCompressionMode(
|
|||||||
FIO_prefs_t* const prefs,
|
FIO_prefs_t* const prefs,
|
||||||
ZSTD_literalCompressionMode_e mode);
|
ZSTD_literalCompressionMode_e mode);
|
||||||
|
|
||||||
void FIO_setNoProgress(unsigned noProgress);
|
void FIO_setProgressSetting(FIO_progressSetting_e progressSetting);
|
||||||
void FIO_setNotificationLevel(int level);
|
void FIO_setNotificationLevel(int level);
|
||||||
void FIO_setExcludeCompressedFile(FIO_prefs_t* const prefs, int excludeCompressedFiles);
|
void FIO_setExcludeCompressedFile(FIO_prefs_t* const prefs, int excludeCompressedFiles);
|
||||||
void FIO_setAllowBlockDevices(FIO_prefs_t* const prefs, int allowBlockDevices);
|
void FIO_setAllowBlockDevices(FIO_prefs_t* const prefs, int allowBlockDevices);
|
||||||
|
|||||||
+4
-2
@@ -167,7 +167,8 @@ static void usage_advanced(const char* programName)
|
|||||||
|
|
||||||
DISPLAYOUT( " -v : verbose mode; specify multiple times to increase verbosity \n");
|
DISPLAYOUT( " -v : verbose mode; specify multiple times to increase verbosity \n");
|
||||||
DISPLAYOUT( " -q : suppress warnings; specify twice to suppress errors too \n");
|
DISPLAYOUT( " -q : suppress warnings; specify twice to suppress errors too \n");
|
||||||
DISPLAYOUT( "--no-progress : do not display the progress counter \n");
|
DISPLAYOUT( "--[no-]progress : forcibly display, or never display the progress counter.\n");
|
||||||
|
DISPLAYOUT( " note: any (de)compressed output to terminal will mix with progress counter text. \n");
|
||||||
|
|
||||||
#ifdef UTIL_HAS_CREATEFILELIST
|
#ifdef UTIL_HAS_CREATEFILELIST
|
||||||
DISPLAYOUT( " -r : operate recursively on directories \n");
|
DISPLAYOUT( " -r : operate recursively on directories \n");
|
||||||
@@ -879,7 +880,8 @@ int main(int const argCount, const char* argv[])
|
|||||||
if (!strcmp(argument, "--rsyncable")) { rsyncable = 1; continue; }
|
if (!strcmp(argument, "--rsyncable")) { rsyncable = 1; continue; }
|
||||||
if (!strcmp(argument, "--compress-literals")) { literalCompressionMode = ZSTD_lcm_huffman; continue; }
|
if (!strcmp(argument, "--compress-literals")) { literalCompressionMode = ZSTD_lcm_huffman; continue; }
|
||||||
if (!strcmp(argument, "--no-compress-literals")) { literalCompressionMode = ZSTD_lcm_uncompressed; continue; }
|
if (!strcmp(argument, "--no-compress-literals")) { literalCompressionMode = ZSTD_lcm_uncompressed; continue; }
|
||||||
if (!strcmp(argument, "--no-progress")) { FIO_setNoProgress(1); continue; }
|
if (!strcmp(argument, "--no-progress")) { FIO_setProgressSetting(FIO_ps_never); continue; }
|
||||||
|
if (!strcmp(argument, "--progress")) { FIO_setProgressSetting(FIO_ps_always); continue; }
|
||||||
if (!strcmp(argument, "--exclude-compressed")) { FIO_setExcludeCompressedFile(prefs, 1); continue; }
|
if (!strcmp(argument, "--exclude-compressed")) { FIO_setExcludeCompressedFile(prefs, 1); continue; }
|
||||||
|
|
||||||
/* long commands with arguments */
|
/* long commands with arguments */
|
||||||
|
|||||||
Reference in New Issue
Block a user