]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added additionalParam
authorinikep <inikep@gmail.com>
Mon, 14 Mar 2016 18:51:11 +0000 (19:51 +0100)
committerinikep <inikep@gmail.com>
Mon, 14 Mar 2016 18:51:11 +0000 (19:51 +0100)
lib/zstd_internal.h
programs/bench.c
programs/bench.h
programs/zstdcli.c

index 409e5e57afec8729dc7bffe9a9fa7e84d4961063..de78bb6f9174930f1a06cfa6b49d21d6c7f72840 100644 (file)
@@ -226,5 +226,7 @@ typedef struct {
 
 seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx);
 
+void ZSTD_setAdditionalParam(ZSTD_CCtx* ctx, int additionalParam);
+
 
 #endif   /* ZSTD_CCOMMON_H_MODULE */
index e233c17fb3aae2ea686f207053e03335fc14d674..94daa36cbd50e95697e0c8c64d6db2a3141d544d 100644 (file)
@@ -64,6 +64,7 @@
 
 #include "mem.h"
 #include "zstd_static.h"
+#include "zstd_internal.h" /* ZSTD_setAdditionalParam */
 #include "xxhash.h"
 #include "datagen.h"      /* RDG_genBuffer */
 
@@ -229,7 +230,7 @@ typedef struct
 #define MAX(a,b) ((a)>(b) ? (a) : (b))
 
 static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
-                        const char* displayName, int cLevel,
+                        const char* displayName, int cLevel, int additionalParam,
                         const size_t* fileSizes, U32 nbFiles,
                         const void* dictBuffer, size_t dictBufferSize, benchResult_t *result)
 {
@@ -280,6 +281,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
     }   }   }
 
     /* warmimg up memory */
+    ZSTD_setAdditionalParam(refCtx, additionalParam);
     RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
 
     /* Bench */
@@ -419,7 +421,7 @@ static size_t BMK_findMaxMem(U64 requiredMem)
 }
 
 static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
-                            const char* displayName, int cLevel, int cLevelLast,
+                            const char* displayName, int cLevel, int cLevelLast, int additionalParam,
                             const size_t* fileSizes, unsigned nbFiles,
                             const void* dictBuffer, size_t dictBufferSize)
 {
@@ -432,15 +434,15 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
 
     memset(&result, 0, sizeof(result));
     memset(&total, 0, sizeof(total));
-    if (g_displayLevel == 1)
+
+     if (g_displayLevel == 1)
         DISPLAY("bench %s: input %u bytes, %i iterations, %u KB blocks\n", ZSTD_VERSION, (U32)benchedSize, nbIterations, (U32)(g_blockSize>>10));
 
     if (cLevelLast < cLevel) cLevelLast = cLevel;
 
     for (l=cLevel; l <= cLevelLast; l++) {           
         BMK_benchMem(srcBuffer, benchedSize,
-                     displayName, l,
+                     displayName, l, additionalParam,
                      fileSizes, nbFiles,
                      dictBuffer, dictBufferSize, &result);
         if (g_displayLevel == 1) {
@@ -494,7 +496,7 @@ static void BMK_loadFiles(void* buffer, size_t bufferSize,
 }
 
 static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
-                               const char* dictFileName, int cLevel, int cLevelLast)
+                               const char* dictFileName, int cLevel, int cLevelLast, int additionalParam)
 {
     void* srcBuffer;
     size_t benchedSize;
@@ -534,7 +536,7 @@ static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
     else displayName = fileNamesTable[0];
 
     BMK_benchCLevel(srcBuffer, benchedSize,
-                    displayName, cLevel, cLevelLast,
+                    displayName, cLevel, cLevelLast, additionalParam,
                     fileSizes, nbFiles,
                     dictBuffer, dictBufferSize);
 
@@ -545,7 +547,7 @@ static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
 }
 
 
-static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility)
+static void BMK_syntheticTest(int cLevel, int cLevelLast, int additionalParam, double compressibility)
 {
     char name[20] = {0};
     size_t benchedSize = 10000000;
@@ -559,7 +561,7 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility
 
     /* Bench */
     snprintf (name, sizeof(name), "Synthetic %2u%%", (unsigned)(compressibility*100));
-    BMK_benchCLevel(srcBuffer, benchedSize, name, cLevel, cLevelLast, &benchedSize, 1, NULL, 0);
+    BMK_benchCLevel(srcBuffer, benchedSize, name, cLevel, cLevelLast, additionalParam, &benchedSize, 1, NULL, 0);
 
     /* clean up */
     free(srcBuffer);
@@ -567,14 +569,14 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility
 
 
 int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
-                   const char* dictFileName, int cLevel, int cLevelLast)
+                   const char* dictFileName, int cLevel, int cLevelLast, int additionalParam)
 {
     double compressibility = (double)g_compressibilityDefault / 100;
 
     if (nbFiles == 0)
-        BMK_syntheticTest(cLevel, cLevelLast, compressibility);
+        BMK_syntheticTest(cLevel, cLevelLast, additionalParam, compressibility);
     else
-        BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast);
+        BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast, additionalParam);
     return 0;
 }
 
index d1d8bd88b7d21a4264dd60bf485a4a628e9cf7f5..5e6d3b18dfe855a5a327cc20c9ddabacb3e31b6e 100644 (file)
@@ -27,7 +27,7 @@
 
 /* Main function */
 int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
-                   const char* dictFileName, int cLevel, int cLevelLast);
+                   const char* dictFileName, int cLevel, int cLevelLast, int additionalParam);
 
 /* Set Parameters */
 void BMK_SetNbIterations(int nbLoops);
index 18fabcfec64ed70d316745b537f0c869899da02b..c986caee3015b640e629c8535941a1e67bcea3b4 100644 (file)
@@ -180,6 +180,7 @@ int main(int argCount, const char** argv)
         nextArgumentIsMaxDict=0;
     unsigned cLevel = 1;
     unsigned cLevelLast = 1;
+    int additionalParam = 0;
     const char** filenameTable = (const char**)malloc(argCount * sizeof(const char*));   /* argCount >= 1 */
     unsigned filenameIdx = 0;
     const char* programName = argv[0];
@@ -191,7 +192,7 @@ int main(int argCount, const char** argv)
     unsigned dictSelect = g_defaultSelectivityLevel;
 
     /* init */
-    (void)cLevelLast; (void)dictCLevel;   /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */
+    (void)additionalParam; (void)cLevelLast; (void)dictCLevel;   /* not used when ZSTD_NOBENCH / ZSTD_NODICT set */
     if (filenameTable==NULL) { DISPLAY("not enough memory\n"); exit(1); }
     displayOut = stderr;
     /* Pick out program name from path. Don't rely on stdlib because of conflicting behavior */
@@ -231,7 +232,6 @@ int main(int argCount, const char** argv)
             argument++;
 
             while (argument[0]!=0) {
-
                 /* compression Level */
                 if ((*argument>='0') && (*argument<='9')) {
                     cLevel = 0;
@@ -331,9 +331,15 @@ int main(int argCount, const char** argv)
                         dictSelect *= 10, dictSelect += *argument++ - '0';
                     break;
 
-                    /* Pause at the end (hidden option) */
-                case 'p': main_pause=1; argument++; break;
-
+                    /* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
+                case 'p': argument++; 
+                    if ((*argument>='0') && (*argument<='9')) {
+                        additionalParam = 0;
+                        while ((*argument >= '0') && (*argument <= '9'))
+                            additionalParam *= 10, additionalParam += *argument++ - '0';
+                        continue;
+                    }
+                    main_pause=1; break;
                     /* unknown command */
                 default : return badusage(programName);
                 }
@@ -375,7 +381,7 @@ int main(int argCount, const char** argv)
     if (bench) {
 #ifndef ZSTD_NOBENCH
         BMK_setNotificationLevel(displayLevel);
-        BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast);
+        BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast, additionalParam);
 #endif
         goto _end;
     }