plugin/lz4: stats option

git-svn-id: svn://ultimatepp.org/upp/trunk@7816 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-10-23 10:30:49 +00:00
parent a2d607295f
commit b4ba7da728
2 changed files with 26 additions and 9 deletions

View file

@ -41,8 +41,6 @@
*/
#define HEAPMODE 0
// #define STATS
/**************************************
CPU Feature Detection
**************************************/
@ -430,10 +428,12 @@ static unsigned LZ4_count(const BYTE* pIn, const BYTE* pRef, const BYTE* pInLimi
return (unsigned)(pIn - pStart);
}
#ifdef STATS
#ifdef LZ4_STATS
int matchOffsetStat[256];
int matchLengthStat[256];
int matchLengthStat[1024];
int matchLengthBig;
int litLengthStat[1024];
int litLengthStatBig;
#endif
static int LZ4_compress_generic(
@ -541,6 +541,12 @@ static int LZ4_compress_generic(
{
/* Encode Literal length */
unsigned litLength = (unsigned)(ip - anchor);
#ifdef LZ4_STATS
if(litLength < 1024)
litLengthStat[litLength]++;
else
litLengthStatBig++;
#endif
token = op++;
if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
return 0; /* Check output limit */
@ -561,7 +567,7 @@ _next_match:
/* Encode Offset */
LZ4_WRITE_LITTLEENDIAN_16(op, (U16)(ip-ref));
#ifdef STATS
#ifdef LZ4_STATS
matchOffsetStat[(U16)(ip-ref) >> 8]++;
#endif
/* Encode MatchLength */
@ -589,11 +595,11 @@ _next_match:
ip += MINMATCH + matchLength;
}
#ifdef STATS
if(matchLength < 256)
matchLengthStat[matchLength]++;
#ifdef LZ4_STATS
if(matchLength + 4 < 1024)
matchLengthStat[matchLength + 4]++;
else
matchLengthBig += matchLength + 4;
matchLengthBig++;
#endif
if (matchLength>=ML_MASK)

View file

@ -317,6 +317,17 @@ char* LZ4_slideInputBuffer (void* state);
int LZ4_decompress_safe_withPrefix64k (const char* source, char* dest, int compressedSize, int maxOutputSize);
int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int originalSize);
#ifdef flagLZ4STATS
#define LZ4_STATS
#endif
#ifdef LZ4_STATS
extern int matchOffsetStat[256];
extern int matchLengthStat[1024];
extern int matchLengthBig;
extern int litLengthStat[1024];
extern int litLengthStatBig;
#endif
#if defined (__cplusplus)
}