]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Updated test-fullbench
authorYann Collet <yann.collet.73@gmail.com>
Wed, 11 Feb 2015 07:34:50 +0000 (08:34 +0100)
committerYann Collet <yann.collet.73@gmail.com>
Wed, 11 Feb 2015 07:34:50 +0000 (08:34 +0100)
programs/Makefile
programs/datagen.c
programs/fullbench.c

index 7aff00d52462aa7cfe50dc60473c228d0474ae5a..bf44cc256817b92eebb74466352e3c37b3d9bedd 100644 (file)
@@ -129,15 +129,11 @@ test-zstd32: zstd32 datagen
 
 test-fullbench: fullbench datagen
        ./fullbench -i1
-       ./datagen -P0 -g516K > tmp
-       ./fullbench -i1 tmp
-       @rm tmp
+       ./fullbench -i1 -P0
 
 test-fullbench32: fullbench32 datagen
        ./fullbench32 -i1
-       ./datagen -P0 -g516K > tmp
-       ./fullbench32 -i1 tmp
-       @rm tmp
+       ./fullbench32 -i1 -P0
 
 test-fuzzer: fuzzer
        ./fuzzer
index 7db7016abfd2bd3186305af560258fe2bd3973a7..f2fc9404eeac4ed302cacd677798b44b292261e2 100644 (file)
@@ -172,6 +172,7 @@ void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba
     if (litProba==0.0) litProba = matchProba / 3.8;
     ldctx = RDG_createLiteralDistrib(litProba);
     RDG_genBlock(buffer, size, 0, matchProba, ldctx, &seed);
+    free(ldctx);
 }
 
 
@@ -203,4 +204,6 @@ void RDG_genOut(unsigned long long size, double matchProba, double litProba, uns
         /* update dict */
         memcpy(fullbuff, buff + (RDG_BLOCKSIZE - RDG_DICTSIZE), RDG_DICTSIZE);
     }
+
+    free(ldctx);
 }
index 0268ba175c92cd3068f882016ece2c2d3d8c5c1f..b94918950dc214c568a34ca7662f384b9e298251 100644 (file)
 #define MAX_MEM    (1984 MB)
 #define DEFAULT_CHUNKSIZE   (4<<20)
 
-static double g_compressibilityDefault = 0.50;
+#define COMPRESSIBILITY_DEFAULT 0.50
 static const size_t sampleSize = 10000000;
 
 
@@ -128,6 +128,7 @@ static const size_t sampleSize = 10000000;
 *  Benchmark Parameters
 **************************************/
 static int nbIterations = NBLOOPS;
+static double g_compressibility = COMPRESSIBILITY_DEFAULT;
 
 void BMK_SetNbIterations(int nbLoops)
 {
@@ -449,7 +450,7 @@ int benchSample(U32 benchNb)
 {
     char* origBuff;
     size_t benchedSize = sampleSize;
-    const char* name = "Sample50";
+    const char* name = "Sample 10MiB";
 
     /* Allocation */
     origBuff = (char*) malloc((size_t)benchedSize);
@@ -460,8 +461,7 @@ int benchSample(U32 benchNb)
     }
 
     /* Fill buffer */
-    //BMK_datagen(origBuff, benchedSize, g_compressibilityDefault, 0);
-    RDG_genBuffer(origBuff, benchedSize, g_compressibilityDefault, 0.0, 0);
+    RDG_genBuffer(origBuff, benchedSize, g_compressibility, 0.0, 0);
 
     /* bench */
     DISPLAY("\r%79s\r", "");
@@ -556,6 +556,7 @@ int usage_advanced(void)
     DISPLAY( "\nAdvanced options :\n");
     DISPLAY( " -b#    : test only function # \n");
     DISPLAY( " -i#    : iteration loops [1-9](default : %i)\n", NBLOOPS);
+    DISPLAY( " -P#    : sample compressibility (default : %.1f%%)\n", COMPRESSIBILITY_DEFAULT * 100);
     return 0;
 }
 
@@ -595,14 +596,14 @@ int main(int argc, char** argv)
 
                 switch(argument[0])
                 {
-                    // Display help on usage
+                    /* Display help on usage */
                 case 'h' :
                 case 'H': usage(exename); usage_advanced(); return 0;
 
-                    // Pause at the end (hidden option)
+                    /* Pause at the end (hidden option) */
                 case 'p': main_pause = 1; break;
 
-                    // Select specific bench algorithm only
+                    /* Select specific algorithm to bench */
                 case 'b':
                     benchNb = 0;
                     while ((argument[1]>= '0') && (argument[1]<= '9'))
@@ -613,7 +614,7 @@ int main(int argc, char** argv)
                     }
                     break;
 
-                    // Modify Nb Iterations
+                    /* Modify Nb Iterations */
                 case 'i':
                     if ((argument[1] >='1') && (argument[1] <='9'))
                     {
@@ -623,14 +624,28 @@ int main(int argc, char** argv)
                     }
                     break;
 
-                    // Unknown command
+                    /* Select specific algorithm to bench */
+                case 'P':
+                    {
+                        U32 proba32 = 0;
+                        while ((argument[1]>= '0') && (argument[1]<= '9'))
+                        {
+                            proba32 *= 10;
+                            proba32 += argument[1] - '0';
+                            argument++;
+                        }
+                        g_compressibility = (double)proba32 / 100.;
+                    }
+                    break;
+
+                    /* Unknown command */
                 default : badusage(exename); return 1;
                 }
             }
             continue;
         }
 
-        // first provided filename is input
+        /* first provided filename is input */
         if (!input_filename) { input_filename=argument; filenamesStart=i; continue; }
     }