Shortened tests durations
This commit is contained in:
parent
42e5bc4a9d
commit
2c7988761d
2
Makefile
2
Makefile
@ -104,7 +104,7 @@ clangtest: clean
|
||||
$(MAKE) all CC=clang CPPFLAGS="-Werror -Wconversion -Wno-sign-conversion"
|
||||
|
||||
sanitize: clean
|
||||
$(MAKE) test CC=clang CPPFLAGS="-g -fsanitize=undefined" FUZZER_TIME="-T5mn"
|
||||
$(MAKE) test CC=clang CPPFLAGS="-g -fsanitize=undefined" FUZZER_TIME="-T1mn"
|
||||
|
||||
staticAnalyze: clean
|
||||
scan-build -v $(MAKE) all CFLAGS=-g
|
||||
|
@ -61,6 +61,7 @@ endif
|
||||
TRAVIS_TARGET:= $(LZ4_TRAVIS_CI_ENV)
|
||||
TEST_FILES := COPYING
|
||||
TEST_TARGETS := test-native
|
||||
FUZZER_TIME := -T9mn
|
||||
|
||||
|
||||
default: lz4
|
||||
|
@ -726,7 +726,7 @@ int FUZ_usage(void)
|
||||
DISPLAY( "\n");
|
||||
DISPLAY( "Arguments :\n");
|
||||
DISPLAY( " -i# : Nb of tests (default:%u) \n", nbTestsDefault);
|
||||
DISPLAY( " -T# : Duration of tests (default: use Nb of tests) \n");
|
||||
DISPLAY( " -T# : Duration of tests, in seconds (default: use Nb of tests) \n");
|
||||
DISPLAY( " -s# : Select seed (default:prompt user)\n");
|
||||
DISPLAY( " -t# : Select starting test number (default:0)\n");
|
||||
DISPLAY( " -p# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT);
|
||||
@ -800,26 +800,23 @@ int main(int argc, char** argv)
|
||||
case 'T':
|
||||
argument++;
|
||||
nbTests = 0; duration = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (argument[0]=='m')
|
||||
switch(*argument)
|
||||
{
|
||||
duration *= 60;
|
||||
argument++;
|
||||
continue;
|
||||
}
|
||||
if (argument[0]=='n')
|
||||
{
|
||||
argument++;
|
||||
continue;
|
||||
}
|
||||
if ((*argument>='0') && (*argument<='9'))
|
||||
{
|
||||
duration *= 10;
|
||||
duration += *argument - '0';
|
||||
argument++;
|
||||
continue;
|
||||
case 'm': duration *= 60; argument++; continue;
|
||||
case 's':
|
||||
case 'n': argument++; continue;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9': duration *= 10; duration += *argument++ - '0'; continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -535,24 +535,22 @@ static int local_LZ4F_decompress(const char* in, char* out, int inSize, int outS
|
||||
|
||||
#define NB_COMPRESSION_ALGORITHMS 100
|
||||
#define NB_DECOMPRESSION_ALGORITHMS 100
|
||||
#define CLEANEXIT(c) { benchStatus = c; goto _clean_up; }
|
||||
int fullSpeedBench(char** fileNamesTable, int nbFiles)
|
||||
{
|
||||
int fileIdx=0;
|
||||
char* orig_buff = NULL;
|
||||
struct chunkParameters* chunkP = NULL;
|
||||
char* compressed_buff=NULL;
|
||||
size_t errorCode;
|
||||
int benchStatus = 0;
|
||||
|
||||
/* Init */
|
||||
errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION);
|
||||
if (LZ4F_isError(errorCode)) { DISPLAY("dctx allocation issue \n"); CLEANEXIT(10); }
|
||||
if (LZ4F_isError(errorCode)) { DISPLAY("dctx allocation issue \n"); return 10; }
|
||||
|
||||
/* Loop for each fileName */
|
||||
while (fileIdx<nbFiles)
|
||||
{
|
||||
FILE* inFile;
|
||||
char* orig_buff = NULL;
|
||||
struct chunkParameters* chunkP = NULL;
|
||||
char* compressed_buff=NULL;
|
||||
char* inFileName;
|
||||
U64 inFileSize;
|
||||
size_t benchedSize;
|
||||
@ -565,25 +563,33 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
|
||||
/* Check file existence */
|
||||
inFileName = fileNamesTable[fileIdx++];
|
||||
inFile = fopen( inFileName, "rb" );
|
||||
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); CLEANEXIT(11); }
|
||||
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
|
||||
|
||||
/* Memory size adjustments */
|
||||
inFileSize = BMK_GetFileSize(inFileName);
|
||||
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); CLEANEXIT(11); }
|
||||
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); return 11; }
|
||||
benchedSize = (size_t) BMK_findMaxMem(inFileSize*2) / 2; /* because 2 buffers */
|
||||
if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); CLEANEXIT(11); }
|
||||
if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); return 11; }
|
||||
if ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
|
||||
if (benchedSize < inFileSize)
|
||||
DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20));
|
||||
|
||||
/* Allocation */
|
||||
chunkP = (struct chunkParameters*) malloc(((benchedSize / (size_t)chunkSize)+1) * sizeof(struct chunkParameters));
|
||||
orig_buff = (char*) malloc((size_t)benchedSize);
|
||||
nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize);
|
||||
orig_buff = (char*) malloc(benchedSize);
|
||||
nbChunks = (int) ((benchedSize + (chunkSize-1)) / chunkSize);
|
||||
maxCompressedChunkSize = LZ4_compressBound(chunkSize);
|
||||
compressedBuffSize = nbChunks * maxCompressedChunkSize;
|
||||
compressed_buff = (char*)malloc((size_t)compressedBuffSize);
|
||||
if(!orig_buff || !compressed_buff) { DISPLAY("\nError: not enough memory!\n"); fclose(inFile); CLEANEXIT(12); }
|
||||
if(!chunkP || !orig_buff || !compressed_buff)
|
||||
{
|
||||
DISPLAY("\nError: not enough memory!\n");
|
||||
fclose(inFile);
|
||||
free(orig_buff);
|
||||
free(compressed_buff);
|
||||
free(chunkP);
|
||||
return(12);
|
||||
}
|
||||
|
||||
/* Fill in src buffer */
|
||||
DISPLAY("Loading %s... \r", inFileName);
|
||||
@ -600,7 +606,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
|
||||
}
|
||||
|
||||
/* Calculating input Checksum */
|
||||
crcOriginal = XXH32(orig_buff, (unsigned int)benchedSize,0);
|
||||
crcOriginal = XXH32(orig_buff, benchedSize,0);
|
||||
|
||||
|
||||
/* Bench */
|
||||
@ -750,7 +756,14 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
|
||||
case 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break;
|
||||
case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress";
|
||||
errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL);
|
||||
if (LZ4F_isError(errorCode)) { DISPLAY("Preparation error compressing frame\n"); CLEANEXIT(1); }
|
||||
if (LZ4F_isError(errorCode))
|
||||
{
|
||||
DISPLAY("Error while preparing compressed frame\n");
|
||||
free(orig_buff);
|
||||
free(compressed_buff);
|
||||
free(chunkP);
|
||||
return 1;
|
||||
}
|
||||
chunkP[0].origSize = (int)benchedSize;
|
||||
chunkP[0].compressedSize = (int)errorCode;
|
||||
nbChunks = 1;
|
||||
@ -798,17 +811,15 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
|
||||
DISPLAY("%2i-%-29.29s :%10i -> %7.1f MB/s\n", dAlgNb, dName, (int)benchedSize, (double)benchedSize / bestTime / 1000.);
|
||||
}
|
||||
}
|
||||
free(orig_buff);
|
||||
free(compressed_buff);
|
||||
free(chunkP);
|
||||
}
|
||||
|
||||
_clean_up:
|
||||
free(orig_buff);
|
||||
free(compressed_buff);
|
||||
free(chunkP);
|
||||
LZ4F_freeDecompressionContext(g_dCtx);
|
||||
|
||||
if (BMK_pause) { printf("press enter...\n"); (void)getchar(); }
|
||||
|
||||
return benchStatus;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ static int FUZ_usage(char* programName)
|
||||
DISPLAY( "\n");
|
||||
DISPLAY( "Arguments :\n");
|
||||
DISPLAY( " -i# : Nb of tests (default:%i) \n", NB_ATTEMPTS);
|
||||
DISPLAY( " -T# : Duration of tests (default: use Nb of tests) \n");
|
||||
DISPLAY( " -T# : Duration of tests, in seconds (default: use Nb of tests) \n");
|
||||
DISPLAY( " -s# : Select seed (default:prompt user)\n");
|
||||
DISPLAY( " -t# : Select starting test number (default:0)\n");
|
||||
DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT);
|
||||
@ -1084,26 +1084,23 @@ int main(int argc, char** argv)
|
||||
case 'T':
|
||||
argument++;
|
||||
nbTests = 0; duration = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (argument[0]=='m')
|
||||
switch(*argument)
|
||||
{
|
||||
duration *= 60;
|
||||
argument++;
|
||||
continue;
|
||||
}
|
||||
if (argument[0]=='n')
|
||||
{
|
||||
argument++;
|
||||
continue;
|
||||
}
|
||||
if ((*argument>='0') && (*argument<='9'))
|
||||
{
|
||||
duration *= 10;
|
||||
duration += *argument - '0';
|
||||
argument++;
|
||||
continue;
|
||||
case 'm': duration *= 60; argument++; continue;
|
||||
case 's':
|
||||
case 'n': argument++; continue;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9': duration *= 10; duration += *argument++ - '0'; continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user