From: Yann Collet Date: Sun, 15 Dec 2024 07:38:18 +0000 (-0800) Subject: fullbench: new scenario: compressSequencesAndLiterals() X-Git-Tag: v1.5.7^2~48^2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f281497aef87a0e6459eef28f695c437a3dec42d;p=thirdparty%2Fzstd.git fullbench: new scenario: compressSequencesAndLiterals() --- diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c index 5aad13531..166208589 100644 --- a/lib/compress/zstd_compress.c +++ b/lib/compress/zstd_compress.c @@ -7227,7 +7227,7 @@ ZSTD_compressSequencesAndLiterals_internal(ZSTD_CCtx* cctx, inSeqs, nbSequences, seqPos); U32 const lastBlock = (blockSize == remaining); FORWARD_IF_ERROR(blockSize, "Error while trying to determine block size"); - RETURN_ERROR_IF(!lastBlock, GENERIC, "Only supports single block"); + RETURN_ERROR_IF(!lastBlock, srcSize_wrong, "Only supports single block"); assert(blockSize <= remaining); ZSTD_resetSeqStore(&cctx->seqStore); diff --git a/tests/fullbench.c b/tests/fullbench.c index 889761ef4..919ae2742 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -567,6 +567,63 @@ static size_t local_compressSequences(const void* input, size_t inputSize, return ZSTD_compressSequences(g_zcc, dst, dstCapacity, seqs, nbSeqs, src, srcSize); } +static PrepResult prepSequencesAndLiterals(const void* src, size_t srcSize, int cLevel) +{ + PrepResult r = PREPRESULT_INIT; + size_t const dstCapacity = ZSTD_compressBound(srcSize); + void* const dst = malloc(dstCapacity); + size_t const prepCapacity = dstCapacity * 4; + void* prepBuffer = malloc(prepCapacity); + void* sequencesStart = (char*)prepBuffer + 3*sizeof(unsigned); + ZSTD_Sequence* const seqs = sequencesStart; + size_t const seqsCapacity = prepCapacity / sizeof(ZSTD_Sequence); + size_t nbSeqs; + ZSTD_CCtx_reset(g_zcc, ZSTD_reset_session_and_parameters); + ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_compressionLevel, cLevel); + nbSeqs = ZSTD_generateSequences(g_zcc, seqs, seqsCapacity, src, srcSize); + CONTROL(srcSize < UINT_MAX); + MEM_write32(prepBuffer, (U32)srcSize); + MEM_write32((char*)prepBuffer+4, (U32)nbSeqs); + /* copy literals */ + { char* const litStart = (char*)(seqs + nbSeqs); + size_t nbLiterals = 0; + const char* ip = src; + size_t n; + for (n=0; n