From: George Lu Date: Mon, 18 Jun 2018 22:06:31 +0000 (-0700) Subject: Fix cli no print X-Git-Tag: v0.0.29~73^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3c8b599901cd3e4a517c066f27c9196ea8c6176;p=thirdparty%2Fzstd.git Fix cli no print Change looping behavior to match old --- diff --git a/programs/bench.c b/programs/bench.c index fae4ea0fa..a9a8086b2 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -818,30 +818,6 @@ static BMK_return_t BMK_benchFileTable(const char* const * const fileNamesTable, } } /* Bench */ - /* - if (adv->separateFiles) { - const BYTE* srcPtr = (const BYTE*)srcBuffer; - U32 fileNb; - res.result.results = (BMK_result_t**)malloc(sizeof(BMK_result_t*) * nbFiles); - res.result.nbFiles = nbFiles; - if(res.result.results == NULL) EXM_THROW(12, BMK_return_t, "not enough memory"); - for (fileNb=0; fileNb ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel(); - /* if (cLevelLast > ZSTD_maxCLevel()) cLevelLast = ZSTD_maxCLevel(); - if (cLevelLast < cLevel) cLevelLast = cLevel; - if (cLevelLast > cLevel) - DISPLAYLEVEL(2, "Benchmarking levels from %d to %d\n", cLevel, cLevelLast); */ - + if (cLevel > ZSTD_maxCLevel()) { + EXM_THROW(15, BMK_return_t, "Invalid Compression Level"); + } if (nbFiles == 0) { return BMK_syntheticTest(cLevel, compressibility, compressionParams, displayLevel, adv); } diff --git a/programs/bench.h b/programs/bench.h index 2030f0a2f..d553e7b4f 100644 --- a/programs/bench.h +++ b/programs/bench.h @@ -75,11 +75,12 @@ typedef struct { BMK_advancedParams_t BMK_initAdvancedParams(void); /* called in cli */ +/* Loads files in fileNamesTable into memory, as well as a dictionary + * from dictFileName, and then uses benchMem */ /* fileNamesTable - name of files to benchmark * nbFiles - number of files (size of fileNamesTable) * dictFileName - name of dictionary file to load - * cLevel - lowest compression level to benchmark - * cLevellast - highest compression level to benchmark (everything in the range [cLevel, cLevellast]) will be benchmarked + * cLevel - compression level to benchmark, errors if invalid * compressionParams - basic compression Parameters * displayLevel - what gets printed * 0 : no display; @@ -103,15 +104,18 @@ BMK_return_t BMK_benchFilesAdvanced(const char** fileNamesTable, unsigned nbFile int cLevel, const ZSTD_compressionParameters* compressionParams, int displayLevel, const BMK_advancedParams_t* const adv); -/* basic benchmarking function, called in paramgrill ctx, dctx must be provided */ +/* basic benchmarking function, called in paramgrill + * applies ZSTD_compress_generic() and ZSTD_decompress_generic() on data in srcBuffer + * with specific compression parameters specified by other arguments using benchFunction + * (cLevel, comprParams + adv in advanced Mode) */ /* srcBuffer - data source, expected to be valid compressed data if in Decode Only Mode * srcSize - size of data in srcBuffer * cLevel - compression level * comprParams - basic compression parameters * dictBuffer - a dictionary if used, null otherwise * dictBufferSize - size of dictBuffer, 0 otherwise - * ctx - Compression Context - * dctx - Decompression Context + * ctx - Compression Context (must be provided) + * dctx - Decompression Context (must be provided) * diplayLevel - see BMK_benchFiles * displayName - name used by display * return @@ -135,7 +139,7 @@ BMK_return_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize, int displayLevel, const char* displayName, const BMK_advancedParams_t* adv); -/* This function benchmarks the running time two functions (function specifics described */ +/* This function times the execution of 2 argument functions, benchFn and initFn */ /* benchFn - (*benchFn)(srcBuffers[i], srcSizes[i], dstBuffers[i], dstCapacities[i], benchPayload) * is run a variable number of times, specified by mode and iter args diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 61a43dc30..63be9ef61 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -32,7 +32,7 @@ #include /* errno */ #include "fileio.h" /* stdinmark, stdoutmark, ZSTD_EXTENSION */ #ifndef ZSTD_NOBENCH -# include "bench.h" /* BMK_benchFiles, BMK_SetNbSeconds */ +# include "bench.h" /* BMK_benchFiles */ #endif #ifndef ZSTD_NODICT # include "dibio.h" /* ZDICT_cover_params_t, DiB_trainFromFiles() */ @@ -816,15 +816,25 @@ int main(int argCount, const char* argv[]) adv.ldmHashEveryLog = g_ldmHashEveryLog; } - for(; cLevel <= cLevelLast; cLevel++) { - if(separateFiles) { - unsigned i; - for(i = 0; i < filenameIdx; i++) { - BMK_benchFilesAdvanced(&filenameTable[i], 1, dictFileName, cLevel, &compressionParams, g_displayLevel, &adv); + if (cLevel > ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel(); + if (cLevelLast > ZSTD_maxCLevel()) cLevelLast = ZSTD_maxCLevel(); + if (cLevelLast < cLevel) cLevelLast = cLevel; + if (cLevelLast > cLevel) + DISPLAYLEVEL(2, "Benchmarking levels from %d to %d\n", cLevel, cLevelLast); + + if(separateFiles) { + unsigned i; + for(i = 0; i < filenameIdx; i++) { + DISPLAYLEVEL(2, "Benchmarking %s \n", filenameTable[i]); + int c; + for(c = cLevel; c <= cLevelLast; c++) { + BMK_benchFilesAdvanced(&filenameTable[i], 1, dictFileName, c, &compressionParams, g_displayLevel, &adv); } - } else { - BMK_benchFilesAdvanced(filenameTable, filenameIdx, dictFileName, cLevel, &compressionParams, g_displayLevel, &adv); } + } else { + for(; cLevel <= cLevelLast; cLevel++) { + BMK_benchFilesAdvanced(filenameTable, filenameIdx, dictFileName, cLevel, &compressionParams, g_displayLevel, &adv); + } } #else