2 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
12 /* **************************************
14 ****************************************/
15 #ifndef BMK_TIMETEST_DEFAULT_S /* default minimum time per test */
16 #define BMK_TIMETEST_DEFAULT_S 3
20 /* **************************************
22 ****************************************/
24 # pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
28 /* *************************************
30 ***************************************/
31 #include "platform.h" /* Large Files support */
32 #include "util.h" /* UTIL_getFileSize, UTIL_sleep */
33 #include <stdlib.h> /* malloc, free */
34 #include <string.h> /* memset */
35 #include <stdio.h> /* fprintf, fopen */
36 #include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
39 #define ZSTD_STATIC_LINKING_ONLY
41 #include "datagen.h" /* RDG_genBuffer */
43 #include "zstdmt_compress.h"
46 /* *************************************
48 ***************************************/
49 #ifndef ZSTD_GIT_COMMIT
50 # define ZSTD_GIT_COMMIT_STRING ""
52 # define ZSTD_GIT_COMMIT_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_GIT_COMMIT)
55 #define TIMELOOP_MICROSEC 1*1000000ULL /* 1 second */
56 #define ACTIVEPERIOD_MICROSEC 70*1000000ULL /* 70 seconds */
57 #define COOLPERIOD_SEC 10
63 static const size_t maxMemory = (sizeof(size_t)==4) ? (2 GB - 64 MB) : (size_t)(1ULL << ((sizeof(size_t)*8)-31));
65 static U32 g_compressibilityDefault = 50;
68 /* *************************************
70 ***************************************/
71 #define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
72 #define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
73 static U32 g_displayLevel = 2; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
75 #define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
76 if ((clock() - g_time > refreshRate) || (g_displayLevel>=4)) \
77 { g_time = clock(); DISPLAY(__VA_ARGS__); \
78 if (g_displayLevel>=4) fflush(stdout); } }
79 static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
80 static clock_t g_time = 0;
83 /* *************************************
85 ***************************************/
89 #define DEBUGOUTPUT(...) if (DEBUG) DISPLAY(__VA_ARGS__);
90 #define EXM_THROW(error, ...) \
92 DEBUGOUTPUT("Error defined at %s, line %i : \n", __FILE__, __LINE__); \
93 DISPLAYLEVEL(1, "Error %i : ", error); \
94 DISPLAYLEVEL(1, __VA_ARGS__); \
95 DISPLAYLEVEL(1, " \n"); \
100 /* *************************************
101 * Benchmark Parameters
102 ***************************************/
103 static int g_additionalParam = 0;
104 static U32 g_decodeOnly = 0;
106 void BMK_setNotificationLevel(unsigned level) { g_displayLevel=level; }
108 void BMK_setAdditionalParam(int additionalParam) { g_additionalParam=additionalParam; }
110 static U32 g_nbSeconds = BMK_TIMETEST_DEFAULT_S;
111 void BMK_setNbSeconds(unsigned nbSeconds)
113 g_nbSeconds = nbSeconds;
114 DISPLAYLEVEL(3, "- test >= %u seconds per compression / decompression - \n", g_nbSeconds);
117 static size_t g_blockSize = 0;
118 void BMK_setBlockSize(size_t blockSize)
120 g_blockSize = blockSize;
121 if (g_blockSize) DISPLAYLEVEL(2, "using blocks of size %u KB \n", (U32)(blockSize>>10));
124 void BMK_setDecodeOnlyMode(unsigned decodeFlag) { g_decodeOnly = (decodeFlag>0); }
126 static U32 g_nbThreads = 1;
127 void BMK_setNbThreads(unsigned nbThreads) {
128 #ifndef ZSTD_MULTITHREAD
129 if (nbThreads > 1) DISPLAYLEVEL(2, "Note : multi-threading is disabled \n");
131 g_nbThreads = nbThreads;
135 /* ********************************************************
137 **********************************************************/
149 #define MIN(a,b) ((a)<(b) ? (a) : (b))
150 #define MAX(a,b) ((a)>(b) ? (a) : (b))
152 static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
153 const char* displayName, int cLevel,
154 const size_t* fileSizes, U32 nbFiles,
155 const void* dictBuffer, size_t dictBufferSize,
156 ZSTD_compressionParameters *comprParams)
158 size_t const blockSize = ((g_blockSize>=32 && !g_decodeOnly) ? g_blockSize : srcSize) + (!srcSize) /* avoid div by 0 */ ;
159 size_t const avgSize = MIN(g_blockSize, (srcSize / nbFiles));
160 U32 const maxNbBlocks = (U32) ((srcSize + (blockSize-1)) / blockSize) + nbFiles;
161 blockParam_t* const blockTable = (blockParam_t*) malloc(maxNbBlocks * sizeof(blockParam_t));
162 size_t const maxCompressedSize = ZSTD_compressBound(srcSize) + (maxNbBlocks * 1024); /* add some room for safety */
163 void* const compressedBuffer = malloc(maxCompressedSize);
164 void* resultBuffer = malloc(srcSize);
165 ZSTDMT_CCtx* const mtctx = ZSTDMT_createCCtx(g_nbThreads);
166 ZSTD_CCtx* const ctx = ZSTD_createCCtx();
167 ZSTD_DCtx* const dctx = ZSTD_createDCtx();
168 size_t const loadedCompressedSize = srcSize;
172 UTIL_freq_t ticksPerSecond;
175 if (!compressedBuffer || !resultBuffer || !blockTable || !ctx || !dctx)
176 EXM_THROW(31, "allocation error : not enough memory");
179 if (strlen(displayName)>17) displayName += strlen(displayName)-17; /* can only display 17 characters */
180 UTIL_initTimer(&ticksPerSecond);
183 const char* srcPtr = (const char*) srcBuffer;
186 for (fileNb=0; fileNb<nbFiles; fileNb++) {
187 U64 const fSize64 = ZSTD_findDecompressedSize(srcPtr, fileSizes[fileNb]);
188 if (fSize64==0) EXM_THROW(32, "Impossible to determine original size ");
190 srcPtr += fileSizes[fileNb];
192 { size_t const decodedSize = (size_t)dSize64;
193 if (dSize64 > decodedSize) EXM_THROW(32, "original size is too large");
194 if (decodedSize==0) EXM_THROW(32, "Impossible to determine original size ");
196 resultBuffer = malloc(decodedSize);
197 if (!resultBuffer) EXM_THROW(33, "not enough memory");
199 srcSize = decodedSize;
200 ratio = (double)srcSize / (double)cSize;
203 /* Init blockTable data */
204 { const char* srcPtr = (const char*)srcBuffer;
205 char* cPtr = (char*)compressedBuffer;
206 char* resPtr = (char*)resultBuffer;
208 for (nbBlocks=0, fileNb=0; fileNb<nbFiles; fileNb++) {
209 size_t remaining = fileSizes[fileNb];
210 U32 const nbBlocksforThisFile = g_decodeOnly ? 1 : (U32)((remaining + (blockSize-1)) / blockSize);
211 U32 const blockEnd = nbBlocks + nbBlocksforThisFile;
212 for ( ; nbBlocks<blockEnd; nbBlocks++) {
213 size_t const thisBlockSize = MIN(remaining, blockSize);
214 blockTable[nbBlocks].srcPtr = (const void*)srcPtr;
215 blockTable[nbBlocks].srcSize = thisBlockSize;
216 blockTable[nbBlocks].cPtr = (void*)cPtr;
217 blockTable[nbBlocks].cRoom = g_decodeOnly ? thisBlockSize : ZSTD_compressBound(thisBlockSize);
218 blockTable[nbBlocks].cSize = blockTable[nbBlocks].cRoom;
219 blockTable[nbBlocks].resPtr = (void*)resPtr;
220 blockTable[nbBlocks].resSize = g_decodeOnly ? (size_t) ZSTD_findDecompressedSize(srcPtr, thisBlockSize) : thisBlockSize;
221 srcPtr += thisBlockSize;
222 cPtr += blockTable[nbBlocks].cRoom;
223 resPtr += thisBlockSize;
224 remaining -= thisBlockSize;
227 /* warmimg up memory */
228 RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
231 { U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
232 U64 const crcOrig = g_decodeOnly ? 0 : XXH64(srcBuffer, srcSize, 0);
233 UTIL_time_t coolTime;
234 U64 const maxTime = (g_nbSeconds * TIMELOOP_MICROSEC) + 1;
235 U64 totalCTime=0, totalDTime=0;
236 U32 cCompleted=g_decodeOnly, dCompleted=0;
238 const char* const marks[NB_MARKS] = { " |", " /", " =", "\\" };
241 UTIL_getTime(&coolTime);
242 DISPLAYLEVEL(2, "\r%79s\r", "");
243 while (!cCompleted || !dCompleted) {
245 /* overheat protection */
246 if (UTIL_clockSpanMicro(coolTime, ticksPerSecond) > ACTIVEPERIOD_MICROSEC) {
247 DISPLAYLEVEL(2, "\rcooling down ... \r");
248 UTIL_sleep(COOLPERIOD_SEC);
249 UTIL_getTime(&coolTime);
253 UTIL_time_t clockStart;
255 DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->\r", marks[markNb], displayName, (U32)srcSize);
256 if (!cCompleted) memset(compressedBuffer, 0xE5, maxCompressedSize); /* warm up and erase result buffer */
258 UTIL_sleepMilli(1); /* give processor time to other processes */
259 UTIL_waitForNextTick(ticksPerSecond);
260 UTIL_getTime(&clockStart);
262 if (!cCompleted) { /* still some time to do compression tests */
263 ZSTD_parameters zparams = ZSTD_getParams(cLevel, avgSize, dictBufferSize);
264 ZSTD_customMem const cmem = { NULL, NULL, NULL };
265 U64 clockLoop = g_nbSeconds ? TIMELOOP_MICROSEC : 1;
267 ZSTD_CDict* const cdict = ZSTD_createCDict_advanced(dictBuffer, dictBufferSize, 1, zparams, cmem);
268 if (cdict==NULL) EXM_THROW(1, "ZSTD_createCDict_advanced() allocation failure");
269 if (comprParams->windowLog) zparams.cParams.windowLog = comprParams->windowLog;
270 if (comprParams->chainLog) zparams.cParams.chainLog = comprParams->chainLog;
271 if (comprParams->hashLog) zparams.cParams.hashLog = comprParams->hashLog;
272 if (comprParams->searchLog) zparams.cParams.searchLog = comprParams->searchLog;
273 if (comprParams->searchLength) zparams.cParams.searchLength = comprParams->searchLength;
274 if (comprParams->targetLength) zparams.cParams.targetLength = comprParams->targetLength;
275 if (comprParams->strategy) zparams.cParams.strategy = (ZSTD_strategy)(comprParams->strategy - 1);
279 for (blockNb=0; blockNb<nbBlocks; blockNb++) {
280 if (dictBufferSize) {
281 rSize = ZSTD_compress_usingCDict(ctx,
282 blockTable[blockNb].cPtr, blockTable[blockNb].cRoom,
283 blockTable[blockNb].srcPtr,blockTable[blockNb].srcSize,
286 #ifdef ZSTD_MULTITHREAD /* note : limitation : MT single-pass does not support compression with dictionary */
287 rSize = ZSTDMT_compressCCtx(mtctx,
288 blockTable[blockNb].cPtr, blockTable[blockNb].cRoom,
289 blockTable[blockNb].srcPtr,blockTable[blockNb].srcSize,
292 rSize = ZSTD_compress_advanced (ctx,
293 blockTable[blockNb].cPtr, blockTable[blockNb].cRoom,
294 blockTable[blockNb].srcPtr,blockTable[blockNb].srcSize, NULL, 0, zparams);
297 if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_compress_usingCDict() failed : %s", ZSTD_getErrorName(rSize));
298 blockTable[blockNb].cSize = rSize;
301 } while (UTIL_clockSpanMicro(clockStart, ticksPerSecond) < clockLoop);
302 ZSTD_freeCDict(cdict);
303 { U64 const clockSpanMicro = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
304 if (clockSpanMicro < fastestC*nbLoops) fastestC = clockSpanMicro / nbLoops;
305 totalCTime += clockSpanMicro;
306 cCompleted = (totalCTime >= maxTime);
310 { U32 blockNb; for (blockNb=0; blockNb<nbBlocks; blockNb++) cSize += blockTable[blockNb].cSize; }
311 ratio = (double)srcSize / (double)cSize;
312 markNb = (markNb+1) % NB_MARKS;
313 DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s\r",
314 marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
315 (double)srcSize / fastestC );
316 } else { /* g_decodeOnly */
317 memcpy(compressedBuffer, srcBuffer, loadedCompressedSize);
320 #if 0 /* disable decompression test */
322 (void)totalDTime; (void)fastestD; (void)crcOrig; /* unused when decompression disabled */
325 if (!dCompleted) memset(resultBuffer, 0xD6, srcSize); /* warm result buffer */
327 UTIL_sleepMilli(1); /* give processor time to other processes */
328 UTIL_waitForNextTick(ticksPerSecond);
331 U64 clockLoop = g_nbSeconds ? TIMELOOP_MICROSEC : 1;
333 UTIL_time_t clockStart;
334 ZSTD_DDict* const ddict = ZSTD_createDDict(dictBuffer, dictBufferSize);
335 if (!ddict) EXM_THROW(2, "ZSTD_createDDict() allocation failure");
336 UTIL_getTime(&clockStart);
339 for (blockNb=0; blockNb<nbBlocks; blockNb++) {
340 size_t const regenSize = ZSTD_decompress_usingDDict(dctx,
341 blockTable[blockNb].resPtr, blockTable[blockNb].resSize,
342 blockTable[blockNb].cPtr, blockTable[blockNb].cSize,
344 if (ZSTD_isError(regenSize)) {
345 DISPLAY("ZSTD_decompress_usingDDict() failed on block %u of size %u : %s \n",
346 blockNb, (U32)blockTable[blockNb].cSize, ZSTD_getErrorName(regenSize));
347 clockLoop = 0; /* force immediate test end */
350 blockTable[blockNb].resSize = regenSize;
353 } while (UTIL_clockSpanMicro(clockStart, ticksPerSecond) < clockLoop);
354 ZSTD_freeDDict(ddict);
355 { U64 const clockSpanMicro = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
356 if (clockSpanMicro < fastestD*nbLoops) fastestD = clockSpanMicro / nbLoops;
357 totalDTime += clockSpanMicro;
358 dCompleted = (totalDTime >= maxTime);
361 markNb = (markNb+1) % NB_MARKS;
362 DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s ,%6.1f MB/s\r",
363 marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
364 (double)srcSize / fastestC,
365 (double)srcSize / fastestD );
368 { U64 const crcCheck = XXH64(resultBuffer, srcSize, 0);
369 if (!g_decodeOnly && (crcOrig!=crcCheck)) {
371 DISPLAY("!!! WARNING !!! %14s : Invalid Checksum : %x != %x \n", displayName, (unsigned)crcOrig, (unsigned)crcCheck);
372 for (u=0; u<srcSize; u++) {
373 if (((const BYTE*)srcBuffer)[u] != ((const BYTE*)resultBuffer)[u]) {
376 DISPLAY("Decoding error at pos %u ", (U32)u);
377 for (segNb = 0; segNb < nbBlocks; segNb++) {
378 if (bacc + blockTable[segNb].srcSize > u) break;
379 bacc += blockTable[segNb].srcSize;
381 pos = (U32)(u - bacc);
382 bNb = pos / (128 KB);
383 DISPLAY("(block %u, sub %u, pos %u) \n", segNb, bNb, pos);
386 for (n=-5; n<0; n++) DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u+n]);
387 DISPLAY(" :%02X: ", ((const BYTE*)srcBuffer)[u]);
388 for (n=1; n<3; n++) DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u+n]);
390 for (n=-5; n<0; n++) DISPLAY("%02X ", ((const BYTE*)resultBuffer)[u+n]);
391 DISPLAY(" :%02X: ", ((const BYTE*)resultBuffer)[u]);
392 for (n=1; n<3; n++) DISPLAY("%02X ", ((const BYTE*)resultBuffer)[u+n]);
397 if (u==srcSize-1) { /* should never happen */
398 DISPLAY("no difference detected\n");
401 } } /* CRC Checking */
403 } /* for (testNb = 1; testNb <= (g_nbSeconds + !g_nbSeconds); testNb++) */
405 if (g_displayLevel == 1) {
406 double cSpeed = (double)srcSize / fastestC;
407 double dSpeed = (double)srcSize / fastestD;
408 if (g_additionalParam)
409 DISPLAY("-%-3i%11i (%5.3f) %6.2f MB/s %6.1f MB/s %s (param=%d)\n", cLevel, (int)cSize, ratio, cSpeed, dSpeed, displayName, g_additionalParam);
411 DISPLAY("-%-3i%11i (%5.3f) %6.2f MB/s %6.1f MB/s %s\n", cLevel, (int)cSize, ratio, cSpeed, dSpeed, displayName);
413 DISPLAYLEVEL(2, "%2i#\n", cLevel);
418 free(compressedBuffer);
420 ZSTDMT_freeCCtx(mtctx);
427 static size_t BMK_findMaxMem(U64 requiredMem)
429 size_t const step = 64 MB;
430 BYTE* testmem = NULL;
432 requiredMem = (((requiredMem >> 26) + 1) << 26);
434 if (requiredMem > maxMemory) requiredMem = maxMemory;
437 testmem = (BYTE*)malloc((size_t)requiredMem);
442 return (size_t)(requiredMem);
445 static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
446 const char* displayName, int cLevel, int cLevelLast,
447 const size_t* fileSizes, unsigned nbFiles,
448 const void* dictBuffer, size_t dictBufferSize,
449 ZSTD_compressionParameters *compressionParams, int setRealTimePrio)
453 const char* pch = strrchr(displayName, '\\'); /* Windows */
454 if (!pch) pch = strrchr(displayName, '/'); /* Linux */
455 if (pch) displayName = pch+1;
457 if (setRealTimePrio) {
458 DISPLAYLEVEL(2, "Note : switching to a real-time priority \n");
459 SET_REALTIME_PRIORITY;
462 if (g_displayLevel == 1 && !g_additionalParam)
463 DISPLAY("bench %s %s: input %u bytes, %u seconds, %u KB blocks\n", ZSTD_VERSION_STRING, ZSTD_GIT_COMMIT_STRING, (U32)benchedSize, g_nbSeconds, (U32)(g_blockSize>>10));
465 if (cLevelLast < cLevel) cLevelLast = cLevel;
467 for (l=cLevel; l <= cLevelLast; l++) {
468 BMK_benchMem(srcBuffer, benchedSize,
471 dictBuffer, dictBufferSize, compressionParams);
476 /*! BMK_loadFiles() :
477 Loads `buffer` with content of files listed within `fileNamesTable`.
478 At most, fills `buffer` entirely */
479 static void BMK_loadFiles(void* buffer, size_t bufferSize,
481 const char** fileNamesTable, unsigned nbFiles)
483 size_t pos = 0, totalSize = 0;
485 for (n=0; n<nbFiles; n++) {
487 U64 fileSize = UTIL_getFileSize(fileNamesTable[n]);
488 if (UTIL_isDirectory(fileNamesTable[n])) {
489 DISPLAYLEVEL(2, "Ignoring %s directory... \n", fileNamesTable[n]);
493 f = fopen(fileNamesTable[n], "rb");
494 if (f==NULL) EXM_THROW(10, "impossible to open file %s", fileNamesTable[n]);
495 DISPLAYUPDATE(2, "Loading %s... \r", fileNamesTable[n]);
496 if (fileSize > bufferSize-pos) fileSize = bufferSize-pos, nbFiles=n; /* buffer too small - stop after this file */
497 { size_t const readSize = fread(((char*)buffer)+pos, 1, (size_t)fileSize, f);
498 if (readSize != (size_t)fileSize) EXM_THROW(11, "could not read %s", fileNamesTable[n]);
500 fileSizes[n] = (size_t)fileSize;
501 totalSize += (size_t)fileSize;
505 if (totalSize == 0) EXM_THROW(12, "no data to bench");
508 static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles, const char* dictFileName, int cLevel,
509 int cLevelLast, ZSTD_compressionParameters *compressionParams, int setRealTimePrio)
513 void* dictBuffer = NULL;
514 size_t dictBufferSize = 0;
515 size_t* fileSizes = (size_t*)malloc(nbFiles * sizeof(size_t));
516 U64 const totalSizeToLoad = UTIL_getTotalFileSize(fileNamesTable, nbFiles);
517 char mfName[20] = {0};
519 if (!fileSizes) EXM_THROW(12, "not enough memory for fileSizes");
521 /* Load dictionary */
522 if (dictFileName != NULL) {
523 U64 dictFileSize = UTIL_getFileSize(dictFileName);
524 if (dictFileSize > 64 MB) EXM_THROW(10, "dictionary file %s too large", dictFileName);
525 dictBufferSize = (size_t)dictFileSize;
526 dictBuffer = malloc(dictBufferSize);
527 if (dictBuffer==NULL) EXM_THROW(11, "not enough memory for dictionary (%u bytes)", (U32)dictBufferSize);
528 BMK_loadFiles(dictBuffer, dictBufferSize, fileSizes, &dictFileName, 1);
531 /* Memory allocation & restrictions */
532 benchedSize = BMK_findMaxMem(totalSizeToLoad * 3) / 3;
533 if ((U64)benchedSize > totalSizeToLoad) benchedSize = (size_t)totalSizeToLoad;
534 if (benchedSize < totalSizeToLoad)
535 DISPLAY("Not enough memory; testing %u MB only...\n", (U32)(benchedSize >> 20));
536 srcBuffer = malloc(benchedSize);
537 if (!srcBuffer) EXM_THROW(12, "not enough memory");
539 /* Load input buffer */
540 BMK_loadFiles(srcBuffer, benchedSize, fileSizes, fileNamesTable, nbFiles);
543 snprintf (mfName, sizeof(mfName), " %u files", nbFiles);
544 { const char* displayName = (nbFiles > 1) ? mfName : fileNamesTable[0];
545 BMK_benchCLevel(srcBuffer, benchedSize,
546 displayName, cLevel, cLevelLast,
548 dictBuffer, dictBufferSize, compressionParams, setRealTimePrio);
558 static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility, ZSTD_compressionParameters* compressionParams, int setRealTimePrio)
561 size_t benchedSize = 10000000;
562 void* const srcBuffer = malloc(benchedSize);
564 /* Memory allocation */
565 if (!srcBuffer) EXM_THROW(21, "not enough memory");
567 /* Fill input buffer */
568 RDG_genBuffer(srcBuffer, benchedSize, compressibility, 0.0, 0);
571 snprintf (name, sizeof(name), "Synthetic %2u%%", (unsigned)(compressibility*100));
572 BMK_benchCLevel(srcBuffer, benchedSize, name, cLevel, cLevelLast, &benchedSize, 1, NULL, 0, compressionParams, setRealTimePrio);
579 int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles, const char* dictFileName,
580 int cLevel, int cLevelLast, ZSTD_compressionParameters* compressionParams, int setRealTimePrio)
582 double const compressibility = (double)g_compressibilityDefault / 100;
584 if (cLevel < 1) cLevel = 1; /* minimum compression level */
585 if (cLevel > ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel();
586 if (cLevelLast > ZSTD_maxCLevel()) cLevelLast = ZSTD_maxCLevel();
587 if (cLevelLast < cLevel) cLevelLast = cLevel;
588 if (cLevelLast > cLevel) DISPLAYLEVEL(2, "Benchmarking levels from %d to %d\n", cLevel, cLevelLast);
591 BMK_syntheticTest(cLevel, cLevelLast, compressibility, compressionParams, setRealTimePrio);
593 BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast, compressionParams, setRealTimePrio);