mirror of
https://github.com/FEX-Emu/xxHash.git
synced 2025-02-03 21:22:43 +00:00
tune xxhsum display messages
This commit is contained in:
parent
9e10157ef3
commit
f3f6e3301c
43
xxhsum.c
43
xxhsum.c
@ -74,7 +74,7 @@ You can contact the author at :
|
||||
//**************************************
|
||||
// Constants
|
||||
//**************************************
|
||||
#define PROGRAM_NAME "xxHash tester"
|
||||
#define PROGRAM_NAME exename
|
||||
#define PROGRAM_VERSION ""
|
||||
#define COMPILED __DATE__
|
||||
#define AUTHOR "Yann Collet"
|
||||
@ -93,16 +93,18 @@ You can contact the author at :
|
||||
|
||||
|
||||
//**************************************
|
||||
// MACRO
|
||||
// Display macros
|
||||
//**************************************
|
||||
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) DISPLAY(__VA_ARGS__);
|
||||
static unsigned displayLevel = 1;
|
||||
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) DISPLAY(__VA_ARGS__);
|
||||
static unsigned g_displayLevel = 1;
|
||||
|
||||
|
||||
//**************************************
|
||||
// Benchmark Parameters
|
||||
// Global variables
|
||||
//**************************************
|
||||
static int nbIterations = NBLOOPS;
|
||||
static int g_nbIterations = NBLOOPS;
|
||||
static int g_fn_selection = 1;
|
||||
|
||||
|
||||
//*********************************************************
|
||||
@ -234,7 +236,7 @@ int BMK_benchFile(char** fileNamesTable, int nbFiles)
|
||||
double fastestC = 100000000.;
|
||||
|
||||
DISPLAY("\r%79s\r", ""); // Clean display line
|
||||
for (interationNb = 1; interationNb <= nbIterations; interationNb++)
|
||||
for (interationNb = 1; interationNb <= g_nbIterations; interationNb++)
|
||||
{
|
||||
int nbHashes = 0;
|
||||
int milliTime;
|
||||
@ -270,7 +272,7 @@ int BMK_benchFile(char** fileNamesTable, int nbFiles)
|
||||
double fastestC = 100000000.;
|
||||
|
||||
DISPLAY("\r%79s\r", ""); // Clean display line
|
||||
for (interationNb = 1; (interationNb <= nbIterations) && ((benchedSize>1)); interationNb++)
|
||||
for (interationNb = 1; (interationNb <= g_nbIterations) && ((benchedSize>1)); interationNb++)
|
||||
{
|
||||
int nbHashes = 0;
|
||||
int milliTime;
|
||||
@ -303,7 +305,7 @@ int BMK_benchFile(char** fileNamesTable, int nbFiles)
|
||||
unsigned long long h64 = 0;
|
||||
|
||||
DISPLAY("\r%79s\r", ""); // Clean display line
|
||||
for (interationNb = 1; interationNb <= nbIterations; interationNb++)
|
||||
for (interationNb = 1; interationNb <= g_nbIterations; interationNb++)
|
||||
{
|
||||
int nbHashes = 0;
|
||||
int milliTime;
|
||||
@ -542,12 +544,13 @@ int BMK_hash(char* fileName, U32 hashNb)
|
||||
|
||||
int usage(char* exename)
|
||||
{
|
||||
DISPLAY( WELCOME_MESSAGE );
|
||||
DISPLAY( "Usage :\n");
|
||||
DISPLAY( " %s [arg] filename\n", exename);
|
||||
DISPLAY( "Arguments :\n");
|
||||
DISPLAY( " -H# : hash selection : 0=32bits, 1=64bits (default %i)\n", 1);
|
||||
DISPLAY( " -H# : hash selection : 0=32bits, 1=64bits (default %i)\n", g_fn_selection);
|
||||
DISPLAY( " -b : benchmark mode \n");
|
||||
DISPLAY( " -i# : number of iterations (benchmark mode; default %i)\n", nbIterations);
|
||||
DISPLAY( " -i# : number of iterations (benchmark mode; default %i)\n", g_nbIterations);
|
||||
DISPLAY( " -h : help (this text)\n");
|
||||
return 0;
|
||||
}
|
||||
@ -566,13 +569,12 @@ int main(int argc, char** argv)
|
||||
int i,
|
||||
filenamesStart=0;
|
||||
char* input_filename=0;
|
||||
int fn_selection = 1;
|
||||
U32 benchmarkMode = 0;
|
||||
|
||||
if (argc<2) return badusage(argv[0]);
|
||||
|
||||
// lz4cat behavior
|
||||
if (strstr(argv[0], "xxh32sum")!=NULL) fn_selection=0;
|
||||
if (strstr(argv[0], "xxh32sum")!=NULL) g_fn_selection=0;
|
||||
|
||||
if (argc<2) return badusage(argv[0]);
|
||||
|
||||
for(i=1; i<argc; i++)
|
||||
{
|
||||
@ -595,7 +597,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// select hash algorithm
|
||||
case 'H':
|
||||
fn_selection = argument[1] - '0';
|
||||
g_fn_selection = argument[1] - '0';
|
||||
argument+=2;
|
||||
break;
|
||||
|
||||
@ -607,7 +609,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Modify Nb Iterations (benchmark only)
|
||||
case 'i':
|
||||
nbIterations = argument[1] - '0';
|
||||
g_nbIterations = argument[1] - '0';
|
||||
argument+=2;
|
||||
break;
|
||||
|
||||
@ -623,9 +625,6 @@ int main(int argc, char** argv)
|
||||
|
||||
}
|
||||
|
||||
// Welcome message
|
||||
DISPLAYLEVEL(2, WELCOME_MESSAGE );
|
||||
|
||||
// Check results are good
|
||||
BMK_sanityCheck();
|
||||
|
||||
@ -634,7 +633,7 @@ int main(int argc, char** argv)
|
||||
// No input filename ==> Error
|
||||
if(!input_filename) { badusage(argv[0]); return 1; }
|
||||
|
||||
if(fn_selection < 0 || fn_selection > 1) { badusage(argv[0]); return 1; }
|
||||
if(g_fn_selection < 0 || g_fn_selection > 1) { badusage(argv[0]); return 1; }
|
||||
|
||||
return BMK_hash(argv[filenamesStart], fn_selection);
|
||||
return BMK_hash(argv[filenamesStart], g_fn_selection);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user