]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
update fullbench for compressStream2() 2319/head
authorYann Collet <yann.collet.73@gmail.com>
Mon, 21 Sep 2020 14:19:20 +0000 (07:19 -0700)
committerYann Collet <yann.collet.73@gmail.com>
Mon, 21 Sep 2020 14:19:20 +0000 (07:19 -0700)
makes it possible to measure scenarios such as #2314

tests/fullbench.c

index 2207239e8f3eb9cb108cb52cbd4d26c7aa3d012d..37f0e242f6c7b4747a9c955e43eafc7a15be228e 100644 (file)
@@ -232,23 +232,40 @@ local_ZSTD_compressStream_freshCCtx(const void* src, size_t srcSize,
     r = local_ZSTD_compressStream(src, srcSize, dst, dstCapacity, payload);
 
     ZSTD_freeCCtx(cctx);
-
     return r;
 }
 
 static size_t
-local_ZSTD_compress_generic_end(const void* src, size_t srcSize,
-                                void* dst, size_t dstCapacity,
-                                void* payload)
+local_ZSTD_compress2(const void* src, size_t srcSize,
+                           void* dst, size_t dstCapacity,
+                           void* payload)
 {
     (void)payload;
     return ZSTD_compress2(g_cstream, dst, dstCapacity, src, srcSize);
 }
 
 static size_t
-local_ZSTD_compress_generic_continue(const void* src, size_t srcSize,
-                                     void* dst, size_t dstCapacity,
-                                     void* payload)
+local_ZSTD_compressStream2_end(const void* src, size_t srcSize,
+    void* dst, size_t dstCapacity,
+    void* payload)
+{
+    ZSTD_outBuffer buffOut;
+    ZSTD_inBuffer buffIn;
+    (void)payload;
+    buffOut.dst = dst;
+    buffOut.size = dstCapacity;
+    buffOut.pos = 0;
+    buffIn.src = src;
+    buffIn.size = srcSize;
+    buffIn.pos = 0;
+    ZSTD_compressStream2(g_cstream, &buffOut, &buffIn, ZSTD_e_end);
+    return buffOut.pos;
+}
+
+static size_t
+local_ZSTD_compressStream2_continue(const void* src, size_t srcSize,
+                                 void* dst, size_t dstCapacity,
+                                 void* payload)
 {
     ZSTD_outBuffer buffOut;
     ZSTD_inBuffer buffIn;
@@ -437,11 +454,17 @@ static int benchMem(unsigned benchNb,
     case 43:
         benchFunction = local_ZSTD_compressStream_freshCCtx; benchName = "compressStream_freshCCtx";
         break;
+    case 50:
+        benchFunction = local_ZSTD_compress2; benchName = "compress2";
+        break;
     case 51:
-        benchFunction = local_ZSTD_compress_generic_continue; benchName = "compress_generic, continue";
+        benchFunction = local_ZSTD_compressStream2_end; benchName = "compressStream2, end";
         break;
     case 52:
-        benchFunction = local_ZSTD_compress_generic_end; benchName = "compress_generic, end";
+        benchFunction = local_ZSTD_compressStream2_end; benchName = "compressStream2, end & short";
+        break;
+    case 53:
+        benchFunction = local_ZSTD_compressStream2_continue; benchName = "compressStream2, continue";
         break;
     case 61:
         benchFunction = local_ZSTD_compress_generic_T2_continue; benchName = "compress_generic, -T2, continue";
@@ -573,6 +596,11 @@ static int benchMem(unsigned benchNb,
         payload = &cparams;
         break;
 
+    case 52 :
+        /* compressStream2, short dstCapacity */
+        dstBuffSize--;
+        break;
+
     /* test functions */
     /* convention: test functions have ID > 100 */