fullbench: tests for ZBUFF_createCCtx_advanced and ZBUFF_createDCtx_advanced

This commit is contained in:
inikep
2016-05-24 10:57:14 +02:00
parent 13ba880b49
commit 71dd67cf57
4 changed files with 66 additions and 10 deletions
+6 -1
View File
@@ -55,8 +55,11 @@ struct ZSTD_stats_s {
/*-*************************************
* Advanced functions
* Stats functions
***************************************/
MEM_STATIC ZSTD_stats_t* ZSTD_statsAlloc() { return malloc(sizeof(ZSTD_stats_t)); }
MEM_STATIC void ZSTD_statsFree(struct ZSTD_stats_s* stats) { free(stats); }
MEM_STATIC void ZSTD_statsPrint(ZSTD_stats_t* stats, U32 searchLength)
{
stats->totalMatchSum += stats->totalSeqSum * ((searchLength == 3) ? 3 : 4);
@@ -155,6 +158,8 @@ MEM_STATIC void ZSTD_statsUpdatePrices(ZSTD_stats_t* stats, size_t litLength, co
#else
struct ZSTD_stats_s { U32 unused; };
MEM_STATIC ZSTD_stats_t* ZSTD_statsAlloc(void) { return NULL; }
MEM_STATIC void ZSTD_statsFree(struct ZSTD_stats_s* stats) { (void)stats; }
MEM_STATIC void ZSTD_statsPrint(ZSTD_stats_t* stats, U32 searchLength) { (void)stats; (void)searchLength; }
MEM_STATIC void ZSTD_statsInit(ZSTD_stats_t* stats) { (void)stats; }
MEM_STATIC void ZSTD_statsResetFreqs(ZSTD_stats_t* stats) { (void)stats; }
+5 -6
View File
@@ -2052,8 +2052,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
BYTE* const ostart = (BYTE*)dst;
BYTE* op = ostart;
const U32 maxDist = 1 << zc->params.cParams.windowLog;
ZSTD_stats_t* stats = (ZSTD_stats_t*) zc->customAlloc(sizeof(ZSTD_stats_t));
if (!stats) return ERROR(memory_allocation);
ZSTD_stats_t* stats = ZSTD_statsAlloc();
zc->seqStore.stats = stats;
ZSTD_statsInit(stats);
@@ -2061,7 +2060,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
size_t cSize;
ZSTD_statsResetFreqs(stats);
if (dstCapacity < ZSTD_blockHeaderSize + MIN_CBLOCK_SIZE) { zc->customFree(stats); return ERROR(dstSize_tooSmall); } /* not enough space to store compressed block */
if (dstCapacity < ZSTD_blockHeaderSize + MIN_CBLOCK_SIZE) { ZSTD_statsFree(stats); return ERROR(dstSize_tooSmall); } /* not enough space to store compressed block */
if (remaining < blockSize) blockSize = remaining;
if ((U32)(ip+blockSize - zc->base) > zc->loadedDictEnd + maxDist) {
@@ -2072,11 +2071,11 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
}
cSize = ZSTD_compressBlock_internal(zc, op+ZSTD_blockHeaderSize, dstCapacity-ZSTD_blockHeaderSize, ip, blockSize);
if (ZSTD_isError(cSize)) { zc->customFree(stats); return cSize; }
if (ZSTD_isError(cSize)) { ZSTD_statsFree(stats); return cSize; }
if (cSize == 0) { /* block is not compressible */
cSize = ZSTD_noCompressBlock(op, dstCapacity, ip, blockSize);
if (ZSTD_isError(cSize)) { zc->customFree(stats); return cSize; }
if (ZSTD_isError(cSize)) { ZSTD_statsFree(stats); return cSize; }
} else {
op[0] = (BYTE)(cSize>>16);
op[1] = (BYTE)(cSize>>8);
@@ -2092,7 +2091,7 @@ static size_t ZSTD_compress_generic (ZSTD_CCtx* zc,
}
ZSTD_statsPrint(stats, zc->params.cParams.searchLength);
zc->customFree(stats);
ZSTD_statsFree(stats);
return op-ostart;
}