From: Yann Collet Date: Thu, 14 Jan 2016 18:13:22 +0000 (+0100) Subject: benchmark uses ZSTD_duplicateCCtx() X-Git-Tag: v0.4.7^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2630a5eadc3cd7f591b747dfc95e3aba271695f0;p=thirdparty%2Fzstd.git benchmark uses ZSTD_duplicateCCtx() --- diff --git a/programs/bench.c b/programs/bench.c index b80d6990b..3c74a572c 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -224,6 +224,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, const size_t maxCompressedSize = ZSTD_compressBound(srcSize) + (maxNbBlocks * 1024); /* add some room for safety */ void* const compressedBuffer = malloc(maxCompressedSize); void* const resultBuffer = malloc(srcSize); + ZSTD_CCtx* refCtx = ZSTD_createCCtx(); ZSTD_CCtx* ctx = ZSTD_createCCtx(); ZSTD_DCtx* dctx = ZSTD_createDCtx(); U64 crcOrig = XXH64(srcBuffer, srcSize, 0); @@ -233,7 +234,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, if (strlen(displayName)>17) displayName += strlen(displayName)-17; /* can only display 17 characters */ /* Memory allocation & restrictions */ - if (!compressedBuffer || !resultBuffer || !blockTable || !ctx || !dctx) + if (!compressedBuffer || !resultBuffer || !blockTable || !refCtx || !ctx || !dctx) EXM_THROW(31, "not enough memory"); /* Init blockTable data */ @@ -291,12 +292,27 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, milliTime = BMK_GetMilliStart(); while (BMK_GetMilliSpan(milliTime) < TIMELOOP) { + ZSTD_compressBegin_advanced(refCtx, ZSTD_getParams(cLevel, dictBufferSize+blockSize)); + ZSTD_compress_insertDictionary(refCtx, dictBuffer, dictBufferSize); for (blockNb=0; blockNb