fixed benchzstd to use new version of benchfn

returning a double type
This commit is contained in:
Yann Collet
2019-01-25 15:11:50 -08:00
parent 8c3ba44ada
commit b8701102e0
2 changed files with 36 additions and 28 deletions
+25 -17
View File
@@ -159,9 +159,13 @@ typedef struct {
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
static void BMK_initCCtx(ZSTD_CCtx* ctx, static void
const void* dictBuffer, size_t dictBufferSize, int cLevel, BMK_initCCtx(ZSTD_CCtx* ctx,
const ZSTD_compressionParameters* comprParams, const BMK_advancedParams_t* adv) { const void* dictBuffer, size_t dictBufferSize,
int cLevel,
const ZSTD_compressionParameters* comprParams,
const BMK_advancedParams_t* adv)
{
ZSTD_CCtx_reset(ctx, ZSTD_reset_session_and_parameters); ZSTD_CCtx_reset(ctx, ZSTD_reset_session_and_parameters);
if (adv->nbWorkers==1) { if (adv->nbWorkers==1) {
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_nbWorkers, 0)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_nbWorkers, 0));
@@ -174,12 +178,12 @@ static void BMK_initCCtx(ZSTD_CCtx* ctx,
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmHashLog, adv->ldmHashLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmHashLog, adv->ldmHashLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmBucketSizeLog, adv->ldmBucketSizeLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmBucketSizeLog, adv->ldmBucketSizeLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmHashRateLog, adv->ldmHashRateLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_ldmHashRateLog, adv->ldmHashRateLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_windowLog, comprParams->windowLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_windowLog, (int)comprParams->windowLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_hashLog, comprParams->hashLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_hashLog, (int)comprParams->hashLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_chainLog, comprParams->chainLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_chainLog, (int)comprParams->chainLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_searchLog, comprParams->searchLog)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_searchLog, (int)comprParams->searchLog));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_minMatch, comprParams->minMatch)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_minMatch, (int)comprParams->minMatch));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_targetLength, comprParams->targetLength)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_targetLength, (int)comprParams->targetLength));
CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_strategy, comprParams->strategy)); CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_strategy, comprParams->strategy));
CHECK_Z(ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize)); CHECK_Z(ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize));
} }
@@ -444,7 +448,7 @@ BMK_benchMemAdvancedNoAlloc(
cSize = cResult.sumOfReturn; cSize = cResult.sumOfReturn;
ratio = (double)srcSize / cSize; ratio = (double)srcSize / cSize;
{ BMK_benchResult_t newResult; { BMK_benchResult_t newResult;
newResult.cSpeed = ((U64)srcSize * TIMELOOP_NANOSEC / cResult.nanoSecPerRun); newResult.cSpeed = (U64)((double)srcSize * TIMELOOP_NANOSEC / cResult.nanoSecPerRun);
benchResult.cSize = cSize; benchResult.cSize = cSize;
if (newResult.cSpeed > benchResult.cSpeed) if (newResult.cSpeed > benchResult.cSpeed)
benchResult.cSpeed = newResult.cSpeed; benchResult.cSpeed = newResult.cSpeed;
@@ -468,7 +472,7 @@ BMK_benchMemAdvancedNoAlloc(
} }
{ BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome); { BMK_runTime_t const dResult = BMK_extract_runTime(dOutcome);
U64 const newDSpeed = (srcSize * TIMELOOP_NANOSEC / dResult.nanoSecPerRun); U64 const newDSpeed = (U64)((double)srcSize * TIMELOOP_NANOSEC / dResult.nanoSecPerRun);
if (newDSpeed > benchResult.dSpeed) if (newDSpeed > benchResult.dSpeed)
benchResult.dSpeed = newDSpeed; benchResult.dSpeed = newDSpeed;
} }
@@ -505,17 +509,21 @@ BMK_benchMemAdvancedNoAlloc(
pos = (U32)(u - bacc); pos = (U32)(u - bacc);
bNb = pos / (128 KB); bNb = pos / (128 KB);
DISPLAY("(sample %u, block %u, pos %u) \n", segNb, bNb, pos); DISPLAY("(sample %u, block %u, pos %u) \n", segNb, bNb, pos);
if (u>5) { { size_t const lowest = (u>5) ? 5 : u;
int n; size_t n;
DISPLAY("origin: "); DISPLAY("origin: ");
for (n=-5; n<0; n++) DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u+n]); for (n=lowest; n>0; n--)
DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u-n]);
DISPLAY(" :%02X: ", ((const BYTE*)srcBuffer)[u]); DISPLAY(" :%02X: ", ((const BYTE*)srcBuffer)[u]);
for (n=1; n<3; n++) DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u+n]); for (n=1; n<3; n++)
DISPLAY("%02X ", ((const BYTE*)srcBuffer)[u+n]);
DISPLAY(" \n"); DISPLAY(" \n");
DISPLAY("decode: "); DISPLAY("decode: ");
for (n=-5; n<0; n++) DISPLAY("%02X ", resultBuffer[u+n]); for (n=lowest; n>0; n++)
DISPLAY("%02X ", resultBuffer[u-n]);
DISPLAY(" :%02X: ", resultBuffer[u]); DISPLAY(" :%02X: ", resultBuffer[u]);
for (n=1; n<3; n++) DISPLAY("%02X ", resultBuffer[u+n]); for (n=1; n<3; n++)
DISPLAY("%02X ", resultBuffer[u+n]);
DISPLAY(" \n"); DISPLAY(" \n");
} }
break; break;
+11 -11
View File
@@ -105,17 +105,17 @@ typedef enum {
} BMK_mode_t; } BMK_mode_t;
typedef struct { typedef struct {
BMK_mode_t mode; /* 0: all, 1: compress only 2: decode only */ BMK_mode_t mode; /* 0: all, 1: compress only 2: decode only */
unsigned nbSeconds; /* default timing is in nbSeconds */ unsigned nbSeconds; /* default timing is in nbSeconds */
size_t blockSize; /* Maximum size of each block*/ size_t blockSize; /* Maximum size of each block*/
unsigned nbWorkers; /* multithreading */ int nbWorkers; /* multithreading */
unsigned realTime; /* real time priority */ unsigned realTime; /* real time priority */
int additionalParam; /* used by python speed benchmark */ int additionalParam; /* used by python speed benchmark */
unsigned ldmFlag; /* enables long distance matching */ int ldmFlag; /* enables long distance matching */
unsigned ldmMinMatch; /* below: parameters for long distance matching, see zstd.1.md */ int ldmMinMatch; /* below: parameters for long distance matching, see zstd.1.md */
unsigned ldmHashLog; int ldmHashLog;
unsigned ldmBucketSizeLog; int ldmBucketSizeLog;
unsigned ldmHashRateLog; int ldmHashRateLog;
} BMK_advancedParams_t; } BMK_advancedParams_t;
/* returns default parameters used by nonAdvanced functions */ /* returns default parameters used by nonAdvanced functions */