Skip to content

Commit

Permalink
Merge pull request #96 from robertu94/pre_encoding
Browse files Browse the repository at this point in the history
added pre-encoding size to stats
  • Loading branch information
robertu94 authored Sep 1, 2022
2 parents 32bd7fe + 84a563a commit c8f7d04
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sz/include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define SZ_VER_MAJOR 2
#define SZ_VER_MINOR 1
#define SZ_VER_BUILD 12
#define SZ_VER_REVISION 3
#define SZ_VER_REVISION 4

#define PASTRI 103
#define HZ 102 //deprecated
Expand Down
3 changes: 3 additions & 0 deletions sz/include/sz_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ typedef struct sz_stats
float zstdCompressionRatio; //not available yet

unsigned int quantization_intervals;

size_t pre_encoding_size;
} sz_stats;

extern sz_stats sz_stat;
Expand All @@ -53,6 +55,7 @@ void writeZstdCompressionRatio(float zstdCompressionRatio);
void writeConstantFlag(int flag);
void writeUnpredictDataCounts(size_t unpredictCount, size_t totalNumElements);
void writeQuantizationInfo(unsigned int quantization_intervals);
void writePreEncodingSize(size_t pre_encoding_size);
void printSZStats();

#ifdef __cplusplus
Expand Down
3 changes: 3 additions & 0 deletions sz/src/sz_double.c
Original file line number Diff line number Diff line change
Expand Up @@ -2717,6 +2717,9 @@ int errBoundMode, double absErr_Bound, double relBoundRatio, double pwRelBoundRa
}
else if(confparams_cpr->szMode==SZ_BEST_COMPRESSION || confparams_cpr->szMode==SZ_DEFAULT_COMPRESSION || confparams_cpr->szMode==SZ_TEMPORAL_COMPRESSION)
{
#if HAVE_WRITESTATS
writePreEncodingSize(tmpOutSize);
#endif
*outSize = sz_lossless_compress(confparams_cpr->losslessCompressor, confparams_cpr->gzipMode, tmpByteData, tmpOutSize, newByteData);
free(tmpByteData);
}
Expand Down
3 changes: 3 additions & 0 deletions sz/src/sz_float.c
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,9 @@ int errBoundMode, double absErr_Bound, double relBoundRatio, double pwRelBoundRa
}
else if(confparams_cpr->szMode==SZ_BEST_COMPRESSION || confparams_cpr->szMode==SZ_DEFAULT_COMPRESSION || confparams_cpr->szMode==SZ_TEMPORAL_COMPRESSION)
{
#if HAVE_WRITESTATS
writePreEncodingSize(tmpOutSize);
#endif
*outSize = sz_lossless_compress(confparams_cpr->losslessCompressor, confparams_cpr->gzipMode, tmpByteData, tmpOutSize, newByteData);
free(tmpByteData);
}
Expand Down
5 changes: 5 additions & 0 deletions sz/src/sz_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ void writeUnpredictDataCounts(size_t unpredictCount, size_t totalNumElements)
sz_stat.unpredictPercent = 1.0f*unpredictCount/totalNumElements;
}

void writePreEncodingSize(size_t pre_encoding_size) {
sz_stat.pre_encoding_size = pre_encoding_size;
}

void printSZStats()
{
printf("===============stats about sz================\n");
Expand Down Expand Up @@ -71,4 +75,5 @@ void printSZStats()
printf("unpredictPercent %f\n", sz_stat.unpredictPercent);

printf("quantization_intervals %u\n", sz_stat.quantization_intervals);
printf("pre_encoding_size %zu\n", sz_stat.pre_encoding_size);
}

0 comments on commit c8f7d04

Please sign in to comment.