Skip to content

Commit 46a2407

Browse files
committed
tools: Add ratio geomean statistics to codectest
Since the cumulative sizes can give a skewed perspective for varied data sets as they depend more on the compressibility of larger files, this change also adds ratio geomean summary for v0, v1, and v1+lz4/zstd.
1 parent 2707593 commit 46a2407

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: tools/codectest.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <vector>
44

5+
#include <math.h>
56
#include <stdio.h>
67
#include <stdlib.h>
78
#include <string.h>
@@ -54,6 +55,11 @@ struct Stats
5455
double v10_zstd;
5556
double count;
5657

58+
double ratio_v0;
59+
double ratio_v1;
60+
double ratio_v1_lz4;
61+
double ratio_v1_zstd;
62+
5763
double total_src;
5864
double total_v0;
5965
double total_v1;
@@ -103,6 +109,9 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
103109
stats->total_src += double(decoded.size());
104110
stats->total_v0 += double(input.size());
105111
stats->total_v1 += double(output.size());
112+
113+
stats->ratio_v0 += log(double(input.size()) / double(decoded.size()));
114+
stats->ratio_v1 += log(double(output.size()) / double(decoded.size()));
106115
}
107116

108117
if (stats && stats->testz)
@@ -117,6 +126,9 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
117126
stats->total_v1_lz4 += output_lz4;
118127
stats->total_v1_zstd += output_zstd;
119128

129+
stats->ratio_v1_lz4 += log(double(output_lz4) / double(decoded.size()));
130+
stats->ratio_v1_zstd += log(double(output_zstd) / double(decoded.size()));
131+
120132
printf("\tlz4 %.2f:", double(decoded_lz4) / double(decoded.size()));
121133
printf(" v0 %.2f", double(input_lz4) / double(decoded.size()));
122134
printf(" v1 %.2f", double(output_lz4) / double(decoded.size()));
@@ -182,6 +194,9 @@ int main(int argc, char** argv)
182194
printf("---\n");
183195
printf("%d files: raw v1/v0 %+.2f%%, lz4 v1/v0 %+.2f%%, zstd v1/v0 %+.2f%%\n",
184196
int(stats.count), stats.v10_raw / stats.count * 100, stats.v10_lz4 / stats.count * 100, stats.v10_zstd / stats.count * 100);
197+
printf("ratio: v0 %.2f, v1 %.2f, v1+lz4 %.2f, v1+zstd %.2f\n",
198+
exp(stats.ratio_v0 / stats.count), exp(stats.ratio_v1 / stats.count),
199+
exp(stats.ratio_v1_lz4 / stats.count), exp(stats.ratio_v1_zstd / stats.count));
185200
printf("total: input %.2f MB, v0 %.2f MB, v1 %.2f MB, v1+lz4 %.2f MB, v1+zstd %.2f MB\n",
186201
stats.total_src / 1024 / 1024, stats.total_v0 / 1024 / 1024, stats.total_v1 / 1024 / 1024,
187202
stats.total_v1_lz4 / 1024 / 1024, stats.total_v1_zstd / 1024 / 1024);

0 commit comments

Comments
 (0)