Shortened tests durations

This commit is contained in:
Yann Collet 2015-04-12 16:40:58 +01:00
parent 42e5bc4a9d
commit 2c7988761d
5 changed files with 63 additions and 57 deletions

View File

@ -104,7 +104,7 @@ clangtest: clean
$(MAKE) all CC=clang CPPFLAGS="-Werror -Wconversion -Wno-sign-conversion" $(MAKE) all CC=clang CPPFLAGS="-Werror -Wconversion -Wno-sign-conversion"
sanitize: clean 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 staticAnalyze: clean
scan-build -v $(MAKE) all CFLAGS=-g scan-build -v $(MAKE) all CFLAGS=-g

View File

@ -61,6 +61,7 @@ endif
TRAVIS_TARGET:= $(LZ4_TRAVIS_CI_ENV) TRAVIS_TARGET:= $(LZ4_TRAVIS_CI_ENV)
TEST_FILES := COPYING TEST_FILES := COPYING
TEST_TARGETS := test-native TEST_TARGETS := test-native
FUZZER_TIME := -T9mn
default: lz4 default: lz4

View File

@ -726,7 +726,7 @@ int FUZ_usage(void)
DISPLAY( "\n"); DISPLAY( "\n");
DISPLAY( "Arguments :\n"); DISPLAY( "Arguments :\n");
DISPLAY( " -i# : Nb of tests (default:%u) \n", nbTestsDefault); 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( " -s# : Select seed (default:prompt user)\n");
DISPLAY( " -t# : Select starting test number (default:0)\n"); DISPLAY( " -t# : Select starting test number (default:0)\n");
DISPLAY( " -p# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT); DISPLAY( " -p# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT);
@ -800,26 +800,23 @@ int main(int argc, char** argv)
case 'T': case 'T':
argument++; argument++;
nbTests = 0; duration = 0; nbTests = 0; duration = 0;
for (;;) for (;;)
{ {
if (argument[0]=='m') switch(*argument)
{ {
duration *= 60; case 'm': duration *= 60; argument++; continue;
argument++; case 's':
continue; case 'n': argument++; continue;
} case '0':
if (argument[0]=='n') case '1':
{ case '2':
argument++; case '3':
continue; case '4':
} case '5':
if ((*argument>='0') && (*argument<='9')) case '6':
{ case '7':
duration *= 10; case '8':
duration += *argument - '0'; case '9': duration *= 10; duration += *argument++ - '0'; continue;
argument++;
continue;
} }
break; break;
} }

View File

@ -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_COMPRESSION_ALGORITHMS 100
#define NB_DECOMPRESSION_ALGORITHMS 100 #define NB_DECOMPRESSION_ALGORITHMS 100
#define CLEANEXIT(c) { benchStatus = c; goto _clean_up; }
int fullSpeedBench(char** fileNamesTable, int nbFiles) int fullSpeedBench(char** fileNamesTable, int nbFiles)
{ {
int fileIdx=0; int fileIdx=0;
char* orig_buff = NULL;
struct chunkParameters* chunkP = NULL;
char* compressed_buff=NULL;
size_t errorCode; size_t errorCode;
int benchStatus = 0;
/* Init */ /* Init */
errorCode = LZ4F_createDecompressionContext(&g_dCtx, LZ4F_VERSION); 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 */ /* Loop for each fileName */
while (fileIdx<nbFiles) while (fileIdx<nbFiles)
{ {
FILE* inFile; FILE* inFile;
char* orig_buff = NULL;
struct chunkParameters* chunkP = NULL;
char* compressed_buff=NULL;
char* inFileName; char* inFileName;
U64 inFileSize; U64 inFileSize;
size_t benchedSize; size_t benchedSize;
@ -565,25 +563,33 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
/* Check file existence */ /* Check file existence */
inFileName = fileNamesTable[fileIdx++]; inFileName = fileNamesTable[fileIdx++];
inFile = fopen( inFileName, "rb" ); 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 */ /* Memory size adjustments */
inFileSize = BMK_GetFileSize(inFileName); 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 */ 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 ((U64)benchedSize > inFileSize) benchedSize = (size_t)inFileSize;
if (benchedSize < inFileSize) if (benchedSize < inFileSize)
DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20)); DISPLAY("Not enough memory for '%s' full size; testing %i MB only...\n", inFileName, (int)(benchedSize>>20));
/* Allocation */ /* Allocation */
chunkP = (struct chunkParameters*) malloc(((benchedSize / (size_t)chunkSize)+1) * sizeof(struct chunkParameters)); chunkP = (struct chunkParameters*) malloc(((benchedSize / (size_t)chunkSize)+1) * sizeof(struct chunkParameters));
orig_buff = (char*) malloc((size_t)benchedSize); orig_buff = (char*) malloc(benchedSize);
nbChunks = (int) (((int)benchedSize + (chunkSize-1))/ chunkSize); nbChunks = (int) ((benchedSize + (chunkSize-1)) / chunkSize);
maxCompressedChunkSize = LZ4_compressBound(chunkSize); maxCompressedChunkSize = LZ4_compressBound(chunkSize);
compressedBuffSize = nbChunks * maxCompressedChunkSize; compressedBuffSize = nbChunks * maxCompressedChunkSize;
compressed_buff = (char*)malloc((size_t)compressedBuffSize); 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 */ /* Fill in src buffer */
DISPLAY("Loading %s... \r", inFileName); DISPLAY("Loading %s... \r", inFileName);
@ -600,7 +606,7 @@ int fullSpeedBench(char** fileNamesTable, int nbFiles)
} }
/* Calculating input Checksum */ /* Calculating input Checksum */
crcOriginal = XXH32(orig_buff, (unsigned int)benchedSize,0); crcOriginal = XXH32(orig_buff, benchedSize,0);
/* Bench */ /* 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 8: decompressionFunction = local_LZ4_decompress_safe_forceExtDict; dName = "LZ4_decompress_safe_forceExtDict"; break;
case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress"; case 9: decompressionFunction = local_LZ4F_decompress; dName = "LZ4F_decompress";
errorCode = LZ4F_compressFrame(compressed_buff, compressedBuffSize, orig_buff, benchedSize, NULL); 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].origSize = (int)benchedSize;
chunkP[0].compressedSize = (int)errorCode; chunkP[0].compressedSize = (int)errorCode;
nbChunks = 1; 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.); 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); LZ4F_freeDecompressionContext(g_dCtx);
if (BMK_pause) { printf("press enter...\n"); (void)getchar(); } if (BMK_pause) { printf("press enter...\n"); (void)getchar(); }
return benchStatus; return 0;
} }

View File

@ -1017,7 +1017,7 @@ static int FUZ_usage(char* programName)
DISPLAY( "\n"); DISPLAY( "\n");
DISPLAY( "Arguments :\n"); DISPLAY( "Arguments :\n");
DISPLAY( " -i# : Nb of tests (default:%i) \n", NB_ATTEMPTS); 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( " -s# : Select seed (default:prompt user)\n");
DISPLAY( " -t# : Select starting test number (default:0)\n"); DISPLAY( " -t# : Select starting test number (default:0)\n");
DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT); DISPLAY( " -P# : Select compressibility in %% (default:%i%%)\n", FUZ_COMPRESSIBILITY_DEFAULT);
@ -1084,26 +1084,23 @@ int main(int argc, char** argv)
case 'T': case 'T':
argument++; argument++;
nbTests = 0; duration = 0; nbTests = 0; duration = 0;
for (;;) for (;;)
{ {
if (argument[0]=='m') switch(*argument)
{ {
duration *= 60; case 'm': duration *= 60; argument++; continue;
argument++; case 's':
continue; case 'n': argument++; continue;
} case '0':
if (argument[0]=='n') case '1':
{ case '2':
argument++; case '3':
continue; case '4':
} case '5':
if ((*argument>='0') && (*argument<='9')) case '6':
{ case '7':
duration *= 10; case '8':
duration += *argument - '0'; case '9': duration *= 10; duration += *argument++ - '0'; continue;
argument++;
continue;
} }
break; break;
} }