mirror of
https://github.com/facebook/zstd.git
synced 2025-08-01 09:47:01 +03:00
added additionalParam
This commit is contained in:
@ -226,5 +226,7 @@ typedef struct {
|
|||||||
|
|
||||||
seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx);
|
seqStore_t ZSTD_copySeqStore(const ZSTD_CCtx* ctx);
|
||||||
|
|
||||||
|
void ZSTD_setAdditionalParam(ZSTD_CCtx* ctx, int additionalParam);
|
||||||
|
|
||||||
|
|
||||||
#endif /* ZSTD_CCOMMON_H_MODULE */
|
#endif /* ZSTD_CCOMMON_H_MODULE */
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "zstd_static.h"
|
#include "zstd_static.h"
|
||||||
|
#include "zstd_internal.h" /* ZSTD_setAdditionalParam */
|
||||||
#include "xxhash.h"
|
#include "xxhash.h"
|
||||||
#include "datagen.h" /* RDG_genBuffer */
|
#include "datagen.h" /* RDG_genBuffer */
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ typedef struct
|
|||||||
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
#define MAX(a,b) ((a)>(b) ? (a) : (b))
|
||||||
|
|
||||||
static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
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 size_t* fileSizes, U32 nbFiles,
|
||||||
const void* dictBuffer, size_t dictBufferSize, benchResult_t *result)
|
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 */
|
/* warmimg up memory */
|
||||||
|
ZSTD_setAdditionalParam(refCtx, additionalParam);
|
||||||
RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
|
RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
|
||||||
|
|
||||||
/* Bench */
|
/* Bench */
|
||||||
@ -419,7 +421,7 @@ static size_t BMK_findMaxMem(U64 requiredMem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
|
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 size_t* fileSizes, unsigned nbFiles,
|
||||||
const void* dictBuffer, size_t dictBufferSize)
|
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(&result, 0, sizeof(result));
|
||||||
memset(&total, 0, sizeof(total));
|
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));
|
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;
|
if (cLevelLast < cLevel) cLevelLast = cLevel;
|
||||||
|
|
||||||
for (l=cLevel; l <= cLevelLast; l++) {
|
for (l=cLevel; l <= cLevelLast; l++) {
|
||||||
BMK_benchMem(srcBuffer, benchedSize,
|
BMK_benchMem(srcBuffer, benchedSize,
|
||||||
displayName, l,
|
displayName, l, additionalParam,
|
||||||
fileSizes, nbFiles,
|
fileSizes, nbFiles,
|
||||||
dictBuffer, dictBufferSize, &result);
|
dictBuffer, dictBufferSize, &result);
|
||||||
if (g_displayLevel == 1) {
|
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,
|
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;
|
void* srcBuffer;
|
||||||
size_t benchedSize;
|
size_t benchedSize;
|
||||||
@ -534,7 +536,7 @@ static void BMK_benchFileTable(const char** fileNamesTable, unsigned nbFiles,
|
|||||||
else displayName = fileNamesTable[0];
|
else displayName = fileNamesTable[0];
|
||||||
|
|
||||||
BMK_benchCLevel(srcBuffer, benchedSize,
|
BMK_benchCLevel(srcBuffer, benchedSize,
|
||||||
displayName, cLevel, cLevelLast,
|
displayName, cLevel, cLevelLast, additionalParam,
|
||||||
fileSizes, nbFiles,
|
fileSizes, nbFiles,
|
||||||
dictBuffer, dictBufferSize);
|
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};
|
char name[20] = {0};
|
||||||
size_t benchedSize = 10000000;
|
size_t benchedSize = 10000000;
|
||||||
@ -559,7 +561,7 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility
|
|||||||
|
|
||||||
/* Bench */
|
/* Bench */
|
||||||
snprintf (name, sizeof(name), "Synthetic %2u%%", (unsigned)(compressibility*100));
|
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 */
|
/* clean up */
|
||||||
free(srcBuffer);
|
free(srcBuffer);
|
||||||
@ -567,14 +569,14 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility
|
|||||||
|
|
||||||
|
|
||||||
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
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;
|
double compressibility = (double)g_compressibilityDefault / 100;
|
||||||
|
|
||||||
if (nbFiles == 0)
|
if (nbFiles == 0)
|
||||||
BMK_syntheticTest(cLevel, cLevelLast, compressibility);
|
BMK_syntheticTest(cLevel, cLevelLast, additionalParam, compressibility);
|
||||||
else
|
else
|
||||||
BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast);
|
BMK_benchFileTable(fileNamesTable, nbFiles, dictFileName, cLevel, cLevelLast, additionalParam);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
/* Main function */
|
/* Main function */
|
||||||
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
|
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 */
|
/* Set Parameters */
|
||||||
void BMK_SetNbIterations(int nbLoops);
|
void BMK_SetNbIterations(int nbLoops);
|
||||||
|
@ -180,6 +180,7 @@ int main(int argCount, const char** argv)
|
|||||||
nextArgumentIsMaxDict=0;
|
nextArgumentIsMaxDict=0;
|
||||||
unsigned cLevel = 1;
|
unsigned cLevel = 1;
|
||||||
unsigned cLevelLast = 1;
|
unsigned cLevelLast = 1;
|
||||||
|
int additionalParam = 0;
|
||||||
const char** filenameTable = (const char**)malloc(argCount * sizeof(const char*)); /* argCount >= 1 */
|
const char** filenameTable = (const char**)malloc(argCount * sizeof(const char*)); /* argCount >= 1 */
|
||||||
unsigned filenameIdx = 0;
|
unsigned filenameIdx = 0;
|
||||||
const char* programName = argv[0];
|
const char* programName = argv[0];
|
||||||
@ -191,7 +192,7 @@ int main(int argCount, const char** argv)
|
|||||||
unsigned dictSelect = g_defaultSelectivityLevel;
|
unsigned dictSelect = g_defaultSelectivityLevel;
|
||||||
|
|
||||||
/* init */
|
/* 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); }
|
if (filenameTable==NULL) { DISPLAY("not enough memory\n"); exit(1); }
|
||||||
displayOut = stderr;
|
displayOut = stderr;
|
||||||
/* Pick out program name from path. Don't rely on stdlib because of conflicting behavior */
|
/* 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++;
|
argument++;
|
||||||
|
|
||||||
while (argument[0]!=0) {
|
while (argument[0]!=0) {
|
||||||
|
|
||||||
/* compression Level */
|
/* compression Level */
|
||||||
if ((*argument>='0') && (*argument<='9')) {
|
if ((*argument>='0') && (*argument<='9')) {
|
||||||
cLevel = 0;
|
cLevel = 0;
|
||||||
@ -331,9 +331,15 @@ int main(int argCount, const char** argv)
|
|||||||
dictSelect *= 10, dictSelect += *argument++ - '0';
|
dictSelect *= 10, dictSelect += *argument++ - '0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Pause at the end (hidden option) */
|
/* Pause at the end (-p) or set an additional param (-p#) (hidden option) */
|
||||||
case 'p': main_pause=1; argument++; break;
|
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 */
|
/* unknown command */
|
||||||
default : return badusage(programName);
|
default : return badusage(programName);
|
||||||
}
|
}
|
||||||
@ -375,7 +381,7 @@ int main(int argCount, const char** argv)
|
|||||||
if (bench) {
|
if (bench) {
|
||||||
#ifndef ZSTD_NOBENCH
|
#ifndef ZSTD_NOBENCH
|
||||||
BMK_setNotificationLevel(displayLevel);
|
BMK_setNotificationLevel(displayLevel);
|
||||||
BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast);
|
BMK_benchFiles(filenameTable, filenameIdx, dictFileName, cLevel, cLevelLast, additionalParam);
|
||||||
#endif
|
#endif
|
||||||
goto _end;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user