]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fullbench: added compress_freshCCtx scenario
authorYann Collet <cyan@fb.com>
Sun, 2 Jan 2022 16:52:33 +0000 (08:52 -0800)
committerYann Collet <cyan@fb.com>
Sun, 2 Jan 2022 16:52:33 +0000 (08:52 -0800)
tests/fullbench.c

index 31b3b6da159da7ccfd3aec93910a457c73c1860d..b55ff767f2f9bdaafa6580b627525460f6c9bc8b 100644 (file)
@@ -108,7 +108,25 @@ local_ZSTD_compress(const void* src, size_t srcSize,
     p.fParams = f;
     p.cParams = *(ZSTD_compressionParameters*)payload;
     return ZSTD_compress_advanced (g_zcc, dst, dstSize, src, srcSize, NULL ,0, p);
-    //return ZSTD_compress(dst, dstSize, src, srcSize, cLevel);
+}
+
+static size_t
+local_ZSTD_compress_freshCCtx(const void* src, size_t srcSize,
+                    void* dst, size_t dstSize,
+                    void* payload)
+{
+    ZSTD_parameters p;
+    ZSTD_frameParameters f = { 1 /* contentSizeHeader*/, 0, 0 };
+    p.fParams = f;
+    p.cParams = *(ZSTD_compressionParameters*)payload;
+    if (g_zcc != NULL) ZSTD_freeCCtx(g_zcc);
+    g_zcc = ZSTD_createCCtx();
+    assert(g_zcc != NULL);
+    {   size_t const r = ZSTD_compress_advanced (g_zcc, dst, dstSize, src, srcSize, NULL ,0, p);
+        ZSTD_freeCCtx(g_zcc);
+        g_zcc = NULL;
+        return r;
+    }
 }
 
 static size_t g_cSize = 0;
@@ -431,6 +449,9 @@ static int benchMem(unsigned benchNb,
     case 2:
         benchFunction = local_ZSTD_decompress; benchName = "decompress";
         break;
+    case 3:
+        benchFunction = local_ZSTD_compress_freshCCtx; benchName = "compress_freshCCtx";
+        break;
 #ifndef ZSTD_DLL_IMPORT
     case 11:
         benchFunction = local_ZSTD_compressContinue; benchName = "compressContinue";
@@ -509,7 +530,6 @@ static int benchMem(unsigned benchNb,
     ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_targetLength, (int)cparams.targetLength);
     ZSTD_CCtx_setParameter(g_zcc, ZSTD_c_strategy, cparams.strategy);
 
-
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_compressionLevel, cLevel);
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_windowLog, (int)cparams.windowLog);
     ZSTD_CCtx_setParameter(g_cstream, ZSTD_c_hashLog, (int)cparams.hashLog);
@@ -528,6 +548,9 @@ static int benchMem(unsigned benchNb,
     case 2:
         g_cSize = ZSTD_compress(dstBuff2, dstBuffSize, src, srcSize, cLevel);
         break;
+    case 3:
+        payload = &cparams;
+        break;
 #ifndef ZSTD_DLL_IMPORT
     case 11:
         payload = &cparams;