mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
changed bench behavior for slow compression levels
This commit is contained in:
@ -190,13 +190,18 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
{ U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
|
{ U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
|
||||||
U64 const crcOrig = XXH64(srcBuffer, srcSize, 0);
|
U64 const crcOrig = XXH64(srcBuffer, srcSize, 0);
|
||||||
UTIL_time_t coolTime;
|
UTIL_time_t coolTime;
|
||||||
U32 testNb;
|
U64 const maxTime = (g_nbIterations * TIMELOOP_MICROSEC) + 100;
|
||||||
|
U64 totalCTime=0, totalDTime=0;
|
||||||
|
U32 cCompleted=0, dCompleted=0;
|
||||||
|
# define NB_MARKS 4
|
||||||
|
const char* const marks[NB_MARKS] = { " |", " /", " =", "\\" };
|
||||||
|
U32 markNb = 0;
|
||||||
size_t cSize = 0;
|
size_t cSize = 0;
|
||||||
double ratio = 0.;
|
double ratio = 0.;
|
||||||
|
|
||||||
UTIL_getTime(&coolTime);
|
UTIL_getTime(&coolTime);
|
||||||
DISPLAYLEVEL(2, "\r%79s\r", "");
|
DISPLAYLEVEL(2, "\r%79s\r", "");
|
||||||
for (testNb = 1; testNb <= (g_nbIterations + !g_nbIterations); testNb++) {
|
while (!cCompleted | !dCompleted) {
|
||||||
UTIL_time_t clockStart;
|
UTIL_time_t clockStart;
|
||||||
U64 clockLoop = g_nbIterations ? TIMELOOP_MICROSEC : 1;
|
U64 clockLoop = g_nbIterations ? TIMELOOP_MICROSEC : 1;
|
||||||
|
|
||||||
@ -208,15 +213,14 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Compression */
|
/* Compression */
|
||||||
DISPLAYLEVEL(2, "%2i-%-17.17s :%10u ->\r", testNb, displayName, (U32)srcSize);
|
DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->\r", marks[markNb], displayName, (U32)srcSize);
|
||||||
memset(compressedBuffer, 0xE5, maxCompressedSize); /* warm up and erase result buffer */
|
if (!cCompleted) memset(compressedBuffer, 0xE5, maxCompressedSize); /* warm up and erase result buffer */
|
||||||
|
|
||||||
UTIL_sleepMilli(1); /* give processor time to other processes */
|
UTIL_sleepMilli(1); /* give processor time to other processes */
|
||||||
UTIL_waitForNextTick(ticksPerSecond);
|
UTIL_waitForNextTick(ticksPerSecond);
|
||||||
UTIL_getTime(&clockStart);
|
UTIL_getTime(&clockStart);
|
||||||
|
|
||||||
{ //size_t const refSrcSize = (nbBlocks == 1) ? srcSize : 0;
|
if (!cCompleted) { /* still some time to do compression tests */
|
||||||
//ZSTD_parameters const zparams = ZSTD_getParams(cLevel, refSrcSize, dictBufferSize);
|
|
||||||
ZSTD_parameters const zparams = ZSTD_getParams(cLevel, blockSize, dictBufferSize);
|
ZSTD_parameters const zparams = ZSTD_getParams(cLevel, blockSize, dictBufferSize);
|
||||||
ZSTD_customMem const cmem = { NULL, NULL, NULL };
|
ZSTD_customMem const cmem = { NULL, NULL, NULL };
|
||||||
U32 nbLoops = 0;
|
U32 nbLoops = 0;
|
||||||
@ -237,13 +241,16 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
ZSTD_freeCDict(cdict);
|
ZSTD_freeCDict(cdict);
|
||||||
{ U64 const clockSpan = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
|
{ U64 const clockSpan = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
|
||||||
if (clockSpan < fastestC*nbLoops) fastestC = clockSpan / nbLoops;
|
if (clockSpan < fastestC*nbLoops) fastestC = clockSpan / nbLoops;
|
||||||
|
totalCTime += clockSpan;
|
||||||
|
cCompleted = totalCTime>maxTime;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
cSize = 0;
|
cSize = 0;
|
||||||
{ U32 blockNb; for (blockNb=0; blockNb<nbBlocks; blockNb++) cSize += blockTable[blockNb].cSize; }
|
{ U32 blockNb; for (blockNb=0; blockNb<nbBlocks; blockNb++) cSize += blockTable[blockNb].cSize; }
|
||||||
ratio = (double)srcSize / (double)cSize;
|
ratio = (double)srcSize / (double)cSize;
|
||||||
DISPLAYLEVEL(2, "%2i-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s\r",
|
markNb = (markNb+1) % NB_MARKS;
|
||||||
testNb, displayName, (U32)srcSize, (U32)cSize, ratio,
|
DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s\r",
|
||||||
|
marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
|
||||||
(double)srcSize / fastestC );
|
(double)srcSize / fastestC );
|
||||||
|
|
||||||
(void)fastestD; (void)crcOrig; /* unused when decompression disabled */
|
(void)fastestD; (void)crcOrig; /* unused when decompression disabled */
|
||||||
@ -255,7 +262,8 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
UTIL_waitForNextTick(ticksPerSecond);
|
UTIL_waitForNextTick(ticksPerSecond);
|
||||||
UTIL_getTime(&clockStart);
|
UTIL_getTime(&clockStart);
|
||||||
|
|
||||||
{ U32 nbLoops = 0;
|
if (!dCompleted) {
|
||||||
|
U32 nbLoops = 0;
|
||||||
ZSTD_DDict* ddict = ZSTD_createDDict(dictBuffer, dictBufferSize);
|
ZSTD_DDict* ddict = ZSTD_createDDict(dictBuffer, dictBufferSize);
|
||||||
if (!ddict) EXM_THROW(2, "ZSTD_createDDict() allocation failure");
|
if (!ddict) EXM_THROW(2, "ZSTD_createDDict() allocation failure");
|
||||||
do {
|
do {
|
||||||
@ -278,10 +286,13 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
ZSTD_freeDDict(ddict);
|
ZSTD_freeDDict(ddict);
|
||||||
{ U64 const clockSpan = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
|
{ U64 const clockSpan = UTIL_clockSpanMicro(clockStart, ticksPerSecond);
|
||||||
if (clockSpan < fastestD*nbLoops) fastestD = clockSpan / nbLoops;
|
if (clockSpan < fastestD*nbLoops) fastestD = clockSpan / nbLoops;
|
||||||
|
totalDTime += clockSpan;
|
||||||
|
dCompleted = totalDTime>maxTime;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
DISPLAYLEVEL(2, "%2i-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s ,%6.1f MB/s\r",
|
markNb = (markNb+1) % NB_MARKS;
|
||||||
testNb, displayName, (U32)srcSize, (U32)cSize, ratio,
|
DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s ,%6.1f MB/s\r",
|
||||||
|
marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
|
||||||
(double)srcSize / fastestC,
|
(double)srcSize / fastestC,
|
||||||
(double)srcSize / fastestD );
|
(double)srcSize / fastestD );
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ Typical gains range from ~10% (at 64KB) to x5 better (at <1KB).
|
|||||||
benchmark file(s) using compression level #
|
benchmark file(s) using compression level #
|
||||||
.TP
|
.TP
|
||||||
.B \-i#
|
.B \-i#
|
||||||
iteration loops [1-9](default : 3), benchmark mode only
|
minimum evaluation time, in seconds (default : 3s), benchmark mode only
|
||||||
.TP
|
.TP
|
||||||
.B \-B#
|
.B \-B#
|
||||||
cut file into independent blocks of size # (default: no block)
|
cut file into independent blocks of size # (default: no block)
|
||||||
|
@ -165,7 +165,7 @@ static int usage_advanced(const char* programName)
|
|||||||
DISPLAY( "Benchmark arguments :\n");
|
DISPLAY( "Benchmark arguments :\n");
|
||||||
DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n");
|
DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n");
|
||||||
DISPLAY( " -e# : test all compression levels from -bX to # (default: 1)\n");
|
DISPLAY( " -e# : test all compression levels from -bX to # (default: 1)\n");
|
||||||
DISPLAY( " -i# : iteration loops [1-9](default : 3)\n");
|
DISPLAY( " -i# : minimum evaluation time in seconds (default : 3s)\n");
|
||||||
DISPLAY( " -B# : cut file into independent blocks of size # (default: no block)\n");
|
DISPLAY( " -B# : cut file into independent blocks of size # (default: no block)\n");
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user