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

Function BMK_benchMemAdvanced

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

Source from the content-addressed store, hash-verified

555}
556
557BMK_benchOutcome_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize,
558 void* dstBuffer, size_t dstCapacity,
559 const size_t* fileSizes, unsigned nbFiles,
560 int cLevel, const ZSTD_compressionParameters* comprParams,
561 const void* dictBuffer, size_t dictBufferSize,
562 int displayLevel, const char* displayName, const BMK_advancedParams_t* adv)
563
564{
565 int const dstParamsError = !dstBuffer ^ !dstCapacity; /* must be both NULL or none */
566
567 size_t const blockSize = ((adv->blockSize>=32 && (adv->mode != BMK_decodeOnly)) ? adv->blockSize : srcSize) + (!srcSize) /* avoid div by 0 */ ;
568 U32 const maxNbBlocks = (U32) ((srcSize + (blockSize-1)) / blockSize) + nbFiles;
569
570 /* these are the blockTable parameters, just split up */
571 const void ** const srcPtrs = (const void**)malloc(maxNbBlocks * sizeof(void*));
572 size_t* const srcSizes = (size_t*)malloc(maxNbBlocks * sizeof(size_t));
573
574
575 void ** const cPtrs = (void**)malloc(maxNbBlocks * sizeof(void*));
576 size_t* const cSizes = (size_t*)malloc(maxNbBlocks * sizeof(size_t));
577 size_t* const cCapacities = (size_t*)malloc(maxNbBlocks * sizeof(size_t));
578
579 void ** const resPtrs = (void**)malloc(maxNbBlocks * sizeof(void*));
580 size_t* const resSizes = (size_t*)malloc(maxNbBlocks * sizeof(size_t));
581
582 BMK_timedFnState_t* timeStateCompress = BMK_createTimedFnState(adv->nbSeconds * 1000, BMK_RUNTEST_DEFAULT_MS);
583 BMK_timedFnState_t* timeStateDecompress = BMK_createTimedFnState(adv->nbSeconds * 1000, BMK_RUNTEST_DEFAULT_MS);
584
585 ZSTD_CCtx* const cctx = ZSTD_createCCtx();
586 ZSTD_DCtx* const dctx = ZSTD_createDCtx();
587
588 const size_t maxCompressedSize = dstCapacity ? dstCapacity : ZSTD_compressBound(srcSize) + (maxNbBlocks * 1024);
589
590 void* const internalDstBuffer = dstBuffer ? NULL : malloc(maxCompressedSize);
591 void* const compressedBuffer = dstBuffer ? dstBuffer : internalDstBuffer;
592
593 BMK_benchOutcome_t outcome = BMK_benchOutcome_error(); /* error by default */
594
595 void* resultBuffer = srcSize ? malloc(srcSize) : NULL;
596
597 int allocationincomplete = !srcPtrs || !srcSizes || !cPtrs ||
598 !cSizes || !cCapacities || !resPtrs || !resSizes ||
599 !timeStateCompress || !timeStateDecompress ||
600 !cctx || !dctx ||
601 !compressedBuffer || !resultBuffer;
602
603
604 if (!allocationincomplete && !dstParamsError) {
605 outcome = BMK_benchMemAdvancedNoAlloc(srcPtrs, srcSizes,
606 cPtrs, cCapacities, cSizes,
607 resPtrs, resSizes,
608 &resultBuffer,
609 compressedBuffer, maxCompressedSize,
610 timeStateCompress, timeStateDecompress,
611 srcBuffer, srcSize,
612 fileSizes, nbFiles,
613 cLevel, comprParams,
614 dictBuffer, dictBufferSize,

Callers 2

BMK_benchMemFunction · 0.85
BMK_benchCLevelFunction · 0.85

Calls 11

mallocFunction · 0.85
BMK_createTimedFnStateFunction · 0.85
BMK_benchOutcome_errorFunction · 0.85
BMK_freeTimedFnStateFunction · 0.85
ZSTD_createCCtxFunction · 0.50
ZSTD_createDCtxFunction · 0.50
ZSTD_compressBoundFunction · 0.50
ZSTD_freeCCtxFunction · 0.50
ZSTD_freeDCtxFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected