BenchMem with block compressed sizes passed back up
This commit is contained in:
+9
-22
@@ -188,7 +188,7 @@ static void BMK_initCCtx(ZSTD_CCtx* ctx,
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_p_searchLog, comprParams->searchLog);
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_p_minMatch, comprParams->searchLength);
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_p_targetLength, comprParams->targetLength);
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_p_compressionStrategy , comprParams->strategy);
|
||||
ZSTD_CCtx_setParameter(ctx, ZSTD_p_compressionStrategy, comprParams->strategy);
|
||||
ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize);
|
||||
}
|
||||
|
||||
@@ -281,8 +281,6 @@ static size_t local_defaultDecompress(
|
||||
|
||||
}
|
||||
|
||||
volatile char g_touched;
|
||||
|
||||
/* initFn will be measured once, bench fn will be measured x times */
|
||||
/* benchFn should return error value or out Size */
|
||||
/* takes # of blocks and list of size & stuff for each. */
|
||||
@@ -293,7 +291,7 @@ BMK_customReturn_t BMK_benchFunction(
|
||||
BMK_initFn_t initFn, void* initPayload,
|
||||
size_t blockCount,
|
||||
const void* const * const srcBlockBuffers, const size_t* srcBlockSizes,
|
||||
void** const dstBlockBuffers, size_t* dstBlockCapacities,
|
||||
void* const * const dstBlockBuffers, size_t* dstBlockCapacitiesToSizes,
|
||||
unsigned nbLoops) {
|
||||
size_t srcSize = 0, dstSize = 0, ind = 0;
|
||||
U64 totalTime;
|
||||
@@ -310,20 +308,13 @@ BMK_customReturn_t BMK_benchFunction(
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
unsigned i, j;
|
||||
size_t i;
|
||||
for(i = 0; i < blockCount; i++) {
|
||||
for(j = 0; j < srcBlockSizes[i]; j++) {
|
||||
g_touched = ((const char*)srcBlockBuffers[i])[j]; /* touch */
|
||||
}
|
||||
}
|
||||
for(i = 0; i < blockCount; i++) {
|
||||
memset(dstBlockBuffers[i], 0xE5, dstBlockCapacities[i]); /* warm up and erase result buffer */
|
||||
memset(dstBlockBuffers[i], 0xE5, dstBlockCapacitiesToSizes[i]); /* warm up and erase result buffer */
|
||||
}
|
||||
|
||||
//UTIL_sleepMilli(5); /* give processor time to other processes */
|
||||
//UTIL_waitForNextTick();
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@@ -332,17 +323,13 @@ BMK_customReturn_t BMK_benchFunction(
|
||||
if(initFn != NULL) { initFn(initPayload); }
|
||||
for(i = 0; i < nbLoops; i++) {
|
||||
for(j = 0; j < blockCount; j++) {
|
||||
size_t res = benchFn(srcBlockBuffers[j], srcBlockSizes[j], dstBlockBuffers[j], dstBlockCapacities[j], benchPayload);
|
||||
size_t res = benchFn(srcBlockBuffers[j], srcBlockSizes[j], dstBlockBuffers[j], dstBlockCapacitiesToSizes[j], benchPayload);
|
||||
if(ZSTD_isError(res)) {
|
||||
EXM_THROW_ND(2, BMK_customReturn_t, "Function benchmarking failed on block %u of size %u : %s \n",
|
||||
j, (U32)dstBlockCapacities[j], ZSTD_getErrorName(res));
|
||||
j, (U32)dstBlockCapacitiesToSizes[j], ZSTD_getErrorName(res));
|
||||
} else if(firstIter) {
|
||||
dstSize += res;
|
||||
//Make compressed blocks continuous
|
||||
if(j != blockCount - 1) {
|
||||
dstBlockBuffers[j+1] = (void*)((char*)dstBlockBuffers[j] + res);
|
||||
dstBlockCapacities[j] = res;
|
||||
}
|
||||
dstBlockCapacitiesToSizes[j] = res;
|
||||
}
|
||||
}
|
||||
firstIter = 0;
|
||||
@@ -382,7 +369,7 @@ BMK_customTimedReturn_t BMK_benchFunctionTimed(
|
||||
BMK_initFn_t initFn, void* initPayload,
|
||||
size_t blockCount,
|
||||
const void* const* const srcBlockBuffers, const size_t* srcBlockSizes,
|
||||
void** const dstBlockBuffers, size_t* dstBlockCapacities)
|
||||
void * const * const dstBlockBuffers, size_t * dstBlockCapacitiesToSizes)
|
||||
{
|
||||
U64 fastest = cont->fastestTime;
|
||||
int completed = 0;
|
||||
@@ -399,7 +386,7 @@ BMK_customTimedReturn_t BMK_benchFunctionTimed(
|
||||
}
|
||||
|
||||
r.result = BMK_benchFunction(benchFn, benchPayload, initFn, initPayload,
|
||||
blockCount, srcBlockBuffers, srcBlockSizes, dstBlockBuffers, dstBlockCapacities, cont->nbLoops);
|
||||
blockCount, srcBlockBuffers, srcBlockSizes, dstBlockBuffers, dstBlockCapacitiesToSizes, cont->nbLoops);
|
||||
if(r.result.error) { /* completed w/ error */
|
||||
r.completed = 1;
|
||||
return r;
|
||||
|
||||
+7
-6
@@ -122,8 +122,6 @@ BMK_return_t BMK_syntheticTest(int cLevel, double compressibility,
|
||||
* (cLevel, comprParams + adv in advanced Mode) */
|
||||
/* srcBuffer - data source, expected to be valid compressed data if in Decode Only Mode
|
||||
* srcSize - size of data in srcBuffer
|
||||
* dstBuffer - destination buffer to write compressed output in, optional (NULL)
|
||||
* dstCapacity - capacity of destination buffer, give 0 if dstBuffer = NULL
|
||||
* cLevel - compression level
|
||||
* comprParams - basic compression parameters
|
||||
* dictBuffer - a dictionary if used, null otherwise
|
||||
@@ -144,7 +142,10 @@ BMK_return_t BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
||||
ZSTD_CCtx* ctx, ZSTD_DCtx* dctx,
|
||||
int displayLevel, const char* displayName);
|
||||
|
||||
/* See benchMem for normal parameter uses and return, see advancedParams_t for adv */
|
||||
/* See benchMem for normal parameter uses and return, see advancedParams_t for adv
|
||||
* dstBuffer - destination buffer to write compressed output in, NULL if none provided.
|
||||
* dstCapacity - capacity of destination buffer, give 0 if dstBuffer = NULL
|
||||
*/
|
||||
BMK_return_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize,
|
||||
void* dstBuffer, size_t dstCapacity,
|
||||
const size_t* fileSizes, unsigned nbFiles,
|
||||
@@ -174,7 +175,7 @@ typedef size_t (*BMK_initFn_t)(void*);
|
||||
* srcBuffers - an array of buffers to be operated on by benchFn
|
||||
* srcSizes - an array of the sizes of above buffers
|
||||
* dstBuffers - an array of buffers to be written into by benchFn
|
||||
* dstCapacities - an array of the capacities of above buffers.
|
||||
* dstCapacitiesToSizes - an array of the capacities of above buffers. Output modified to compressed sizes of those blocks.
|
||||
* nbLoops - defines number of times benchFn is run.
|
||||
* return
|
||||
* .error will give a nonzero value if ZSTD_isError() is nonzero for any of the return
|
||||
@@ -191,7 +192,7 @@ BMK_customReturn_t BMK_benchFunction(
|
||||
BMK_initFn_t initFn, void* initPayload,
|
||||
size_t blockCount,
|
||||
const void* const * const srcBuffers, const size_t* srcSizes,
|
||||
void** const dstBuffers, size_t* dstCapacities,
|
||||
void * const * const dstBuffers, size_t* dstCapacitiesToSizes,
|
||||
unsigned nbLoops);
|
||||
|
||||
|
||||
@@ -220,7 +221,7 @@ BMK_customTimedReturn_t BMK_benchFunctionTimed(BMK_timedFnState_t* cont,
|
||||
BMK_initFn_t initFn, void* initPayload,
|
||||
size_t blockCount,
|
||||
const void* const * const srcBlockBuffers, const size_t* srcBlockSizes,
|
||||
void** const dstBlockBuffers, size_t* dstBlockCapacities);
|
||||
void* const * const dstBlockBuffers, size_t* dstBlockCapacitiesToSizes);
|
||||
|
||||
#endif /* BENCH_H_121279284357 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user