#define CDG_SIZE_DEFAULT (64 KB)
#define CDG_SEED_DEFAULT 0
#define CDG_COMPRESSIBILITY_DEFAULT 50
+#define CDG_LITDENSITY_DEFAULT 12
#define PRIME1 2654435761U
#define PRIME2 2246822519U
* Local Parameters
**************************************/
static unsigned no_prompt = 0;
-static char* programName;
static unsigned displayLevel = 2;
#define CDG_RAND15BITS ((CDG_rand(seed) >> 3) & 32767)
#define CDG_RANDLENGTH ( ((CDG_rand(seed) >> 7) & 7) ? (CDG_rand(seed) & 15) : (CDG_rand(seed) & 511) + 15)
#define CDG_DICTSIZE (32 KB)
-static void CDG_generate(U64 size, U32* seed, double matchProba)
+static void CDG_generate(U64 size, U32* seed, double matchProba, double litProba)
{
BYTE fullbuff[CDG_DICTSIZE + 128 KB + 1];
BYTE* buff = fullbuff + CDG_DICTSIZE;
U32 P32 = (U32)(32768 * matchProba);
U32 pos=1;
U32 genBlockSize = 128 KB;
- double literalDistrib = 0.13;
- void* ldctx = CDG_createLiteralDistrib(literalDistrib);
+ void* ldctx = CDG_createLiteralDistrib(litProba);
/* Build initial prefix */
fullbuff[0] = CDG_genChar(seed, ldctx);
/*********************************************************
* Command line
*********************************************************/
-static int CDG_usage(void)
+static int CDG_usage(char* programName)
{
DISPLAY( "Compressible data generator\n");
DISPLAY( "Usage :\n");
int main(int argc, char** argv)
{
int argNb;
- int proba = CDG_COMPRESSIBILITY_DEFAULT;
+ U32 proba = CDG_COMPRESSIBILITY_DEFAULT;
+ U32 litProba = CDG_LITDENSITY_DEFAULT;
U64 size = CDG_SIZE_DEFAULT;
U32 seed = CDG_SEED_DEFAULT;
+ char* programName;
/* Check command line */
programName = argv[0];
switch(*argument)
{
case 'h':
- return CDG_usage();
+ return CDG_usage(programName);
case 'g':
argument++;
size=0;
argument++;
}
break;
- case 'p':
+ case 'P':
argument++;
proba=0;
while ((*argument>='0') && (*argument<='9'))
proba += *argument - '0';
argument++;
}
- if (proba<0) proba=0;
if (proba>100) proba=100;
break;
+ case 'L':
+ argument++;
+ litProba=0;
+ while ((*argument>='0') && (*argument<='9'))
+ {
+ litProba *= 10;
+ litProba += *argument - '0';
+ argument++;
+ }
+ if (litProba>100) litProba=100;
+ break;
case 'v':
displayLevel = 4;
argument++;
break;
- default: ;
+ default:
+ return CDG_usage(programName);
}
}
DISPLAYLEVEL(3, "Seed = %u \n", seed);
if (proba!=CDG_COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", proba);
- CDG_generate(size, &seed, ((double)proba) / 100);
+ CDG_generate(size, &seed, ((double)proba) / 100, ((double)litProba) / 100);
return 0;
}
}
/* Allocation */
- dstBuffSize = srcSize + 512;
+ dstBuffSize = ZSTD_compressBound(srcSize);
dstBuff = malloc(dstBuffSize);
buff2 = malloc(dstBuffSize);
if ((!dstBuff) || (!buff2))
DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20));
}
- // Alloc
+ /* Alloc */
origBuff = (char*) malloc((size_t)benchedSize);
if(!origBuff)
{
return 12;
}
- // Fill input buffer
+ /* Fill input buffer */
DISPLAY("Loading %s... \r", inFileName);
readSize = fread(origBuff, 1, benchedSize, inFile);
fclose(inFile);
return 13;
}
- // bench
+ /* bench */
DISPLAY("\r%79s\r", "");
DISPLAY(" %s : \n", inFileName);
if (benchNb)