MCPcopy Create free account
hub / github.com/F-Stack/f-stack / BMK_benchMemAdvancedNoAlloc

Function BMK_benchMemAdvancedNoAlloc

freebsd/contrib/zstd/programs/benchzstd.c:298–555  ·  view source on GitHub ↗

benchMem with no allocation */

Source from the content-addressed store, hash-verified

296
297/* benchMem with no allocation */
298static BMK_benchOutcome_t
299BMK_benchMemAdvancedNoAlloc(
300 const void** srcPtrs, size_t* srcSizes,
301 void** cPtrs, size_t* cCapacities, size_t* cSizes,
302 void** resPtrs, size_t* resSizes,
303 void** resultBufferPtr, void* compressedBuffer,
304 size_t maxCompressedSize,
305 BMK_timedFnState_t* timeStateCompress,
306 BMK_timedFnState_t* timeStateDecompress,
307
308 const void* srcBuffer, size_t srcSize,
309 const size_t* fileSizes, unsigned nbFiles,
310 const int cLevel,
311 const ZSTD_compressionParameters* comprParams,
312 const void* dictBuffer, size_t dictBufferSize,
313 ZSTD_CCtx* cctx, ZSTD_DCtx* dctx,
314 int displayLevel, const char* displayName,
315 const BMK_advancedParams_t* adv)
316{
317 size_t const blockSize = ((adv->blockSize>=32 && (adv->mode != BMK_decodeOnly)) ? adv->blockSize : srcSize) + (!srcSize); /* avoid div by 0 */
318 BMK_benchResult_t benchResult;
319 size_t const loadedCompressedSize = srcSize;
320 size_t cSize = 0;
321 double ratio = 0.;
322 U32 nbBlocks;
323
324 assert(cctx != NULL); assert(dctx != NULL);
325
326 /* init */
327 memset(&benchResult, 0, sizeof(benchResult));
328 if (strlen(displayName)>17) displayName += strlen(displayName) - 17; /* display last 17 characters */
329 if (adv->mode == BMK_decodeOnly) { /* benchmark only decompression : source must be already compressed */
330 const char* srcPtr = (const char*)srcBuffer;
331 U64 totalDSize64 = 0;
332 U32 fileNb;
333 for (fileNb=0; fileNb<nbFiles; fileNb++) {
334 U64 const fSize64 = ZSTD_findDecompressedSize(srcPtr, fileSizes[fileNb]);
335 if (fSize64==0) RETURN_ERROR(32, BMK_benchOutcome_t, "Impossible to determine original size ");
336 totalDSize64 += fSize64;
337 srcPtr += fileSizes[fileNb];
338 }
339 { size_t const decodedSize = (size_t)totalDSize64;
340 assert((U64)decodedSize == totalDSize64); /* check overflow */
341 free(*resultBufferPtr);
342 *resultBufferPtr = malloc(decodedSize);
343 if (!(*resultBufferPtr)) {
344 RETURN_ERROR(33, BMK_benchOutcome_t, "not enough memory");
345 }
346 if (totalDSize64 > decodedSize) { /* size_t overflow */
347 free(*resultBufferPtr);
348 RETURN_ERROR(32, BMK_benchOutcome_t, "original size is too large");
349 }
350 cSize = srcSize;
351 srcSize = decodedSize;
352 ratio = (double)srcSize / (double)cSize;
353 }
354 }
355

Callers 1

BMK_benchMemAdvancedFunction · 0.85

Calls 15

memsetFunction · 0.85
mallocFunction · 0.85
RDG_genBufferFunction · 0.85
BMK_benchTimedFnFunction · 0.85
BMK_benchOutcome_errorFunction · 0.85
BMK_extract_runTimeFunction · 0.85
BMK_isCompleted_TimedFnFunction · 0.85
freeFunction · 0.50
ZSTD_compressBoundFunction · 0.50

Tested by

no test coverage detected