]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
added -T command , to set nb of threads
authorYann Collet <cyan@fb.com>
Wed, 28 Dec 2016 15:11:09 +0000 (16:11 +0100)
committerYann Collet <cyan@fb.com>
Wed, 28 Dec 2016 15:11:09 +0000 (16:11 +0100)
programs/bench.c
programs/bench.h
programs/zstdcli.c

index 4059072f0fb9ed2e7b57dbdc9a6344809cdfc233..6009ebc7b5b31917121600da6dd1942f76d8673f 100644 (file)
@@ -96,6 +96,7 @@ static U32 g_nbSeconds = NBSECONDS;
 static size_t g_blockSize = 0;
 static int g_additionalParam = 0;
 static U32 g_decodeOnly = 0;
+static U32 g_nbThreads = 1;
 
 void BMK_setNotificationLevel(unsigned level) { g_displayLevel=level; }
 
@@ -113,7 +114,9 @@ void BMK_SetBlockSize(size_t blockSize)
     DISPLAYLEVEL(2, "using blocks of size %u KB \n", (U32)(blockSize>>10));
 }
 
-void BMK_setDecodeOnly(unsigned decodeFlag) { g_decodeOnly = (decodeFlag>0); }
+void BMK_setDecodeOnlyMode(unsigned decodeFlag) { g_decodeOnly = (decodeFlag>0); }
+
+void BMK_SetNbThreads(unsigned nbThreads) { g_nbThreads = nbThreads; }
 
 
 /* ********************************************************
@@ -156,7 +159,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
     U32 nbBlocks;
     UTIL_time_t ticksPerSecond;
 
-    ZSTDMT_CCtx* const mtcctx = ZSTDMT_createCCtx(1);
+    ZSTDMT_CCtx* const mtcctx = ZSTDMT_createCCtx(g_nbThreads);
 
     /* checks */
     if (!compressedBuffer || !resultBuffer || !blockTable || !ctx || !dctx)
index 314f34655766a342af5a67ef1db27f289461f1e4..87850bcc30ec26f67753530e1d1fc47ac261827e 100644 (file)
 #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_compressionParameters */
 #include "zstd.h"     /* ZSTD_compressionParameters */
 
-int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,const char* dictFileName, 
+int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,const char* dictFileName,
                    int cLevel, int cLevelLast, ZSTD_compressionParameters* compressionParams);
 
 /* Set Parameters */
 void BMK_SetNbSeconds(unsigned nbLoops);
 void BMK_SetBlockSize(size_t blockSize);
-void BMK_setAdditionalParam(int additionalParam);
+void BMK_SetNbThreads(unsigned nbThreads);
 void BMK_setNotificationLevel(unsigned level);
-void BMK_setDecodeOnly(unsigned decodeFlag);
+void BMK_setAdditionalParam(int additionalParam);
+void BMK_setDecodeOnlyMode(unsigned decodeFlag);
 
 #endif   /* BENCH_H_121279284357 */
index 978ffcfe08cacce3a81886289030b5bd7d584145..03ad1ac7e507a890637f055a1ec4bcc415a0d21d 100644 (file)
@@ -352,7 +352,7 @@ int main(int argCount, const char* argv[])
                          /* Decoding */
                     case 'd':
 #ifndef ZSTD_NOBENCH
-                            if (operation==zom_bench) { BMK_setDecodeOnly(1); argument++; break; }  /* benchmark decode (hidden option) */
+                            if (operation==zom_bench) { BMK_setDecodeOnlyMode(1); argument++; break; }  /* benchmark decode (hidden option) */
 #endif
                             operation=zom_decompress; argument++; break;
 
@@ -430,6 +430,12 @@ int main(int argCount, const char* argv[])
                         dictSelect = readU32FromChar(&argument);
                         break;
 
+                        /* nb of threads (hidden option) */
+                    case 'T':
+                        argument++;
+                        BMK_SetNbThreads(readU32FromChar(&argument));
+                        break;
+
                         /* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
                     case 'p': argument++;
 #ifndef ZSTD_NOBENCH