Skip to content

Commit 2707593

Browse files
committed
tools: Add cumulative size stats to codectest
As v1 is getting wrapped up, v0-v1 comparison is less valuable compared to the absolute sizes. It might make sense to replace the cumulative ratio improvement stats with something like a ratio geomean, but for now add total size (which is skewed towards larger input files, but is an accurate representation of total disk size or load time impact for a given set).
1 parent e76123e commit 2707593

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/codectest.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ struct Stats
5353
double v10_lz4;
5454
double v10_zstd;
5555
double count;
56+
57+
double total_src;
58+
double total_v0;
59+
double total_v1;
60+
double total_v1_lz4;
61+
double total_v1_zstd;
5662
};
5763

5864
void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats = 0)
@@ -93,6 +99,10 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
9399
{
94100
stats->v10_raw += double(output.size()) / double(input.size()) - 1;
95101
stats->count++;
102+
103+
stats->total_src += double(decoded.size());
104+
stats->total_v0 += double(input.size());
105+
stats->total_v1 += double(output.size());
96106
}
97107

98108
if (stats && stats->testz)
@@ -104,6 +114,9 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
104114
size_t input_zstd = measure_zstd(input);
105115
size_t output_zstd = measure_zstd(output);
106116

117+
stats->total_v1_lz4 += output_lz4;
118+
stats->total_v1_zstd += output_zstd;
119+
107120
printf("\tlz4 %.2f:", double(decoded_lz4) / double(decoded.size()));
108121
printf(" v0 %.2f", double(input_lz4) / double(decoded.size()));
109122
printf(" v1 %.2f", double(output_lz4) / double(decoded.size()));
@@ -169,6 +182,9 @@ int main(int argc, char** argv)
169182
printf("---\n");
170183
printf("%d files: raw v1/v0 %+.2f%%, lz4 v1/v0 %+.2f%%, zstd v1/v0 %+.2f%%\n",
171184
int(stats.count), stats.v10_raw / stats.count * 100, stats.v10_lz4 / stats.count * 100, stats.v10_zstd / stats.count * 100);
185+
printf("total: input %.2f MB, v0 %.2f MB, v1 %.2f MB, v1+lz4 %.2f MB, v1+zstd %.2f MB\n",
186+
stats.total_src / 1024 / 1024, stats.total_v0 / 1024 / 1024, stats.total_v1 / 1024 / 1024,
187+
stats.total_v1_lz4 / 1024 / 1024, stats.total_v1_zstd / 1024 / 1024);
172188
return 0;
173189
}
174190

0 commit comments

Comments
 (0)