Skip to content

Commit 8e716e4

Browse files
committed
tools: Remove v1/v0 gain statistics from codectest
Since v1 is now more or less a fixed quantity, comparing it to v0 is no longer useful; instead further analysis should focus on ratio. This change removes output of v0/v1 ratio and removes v0 lz4/zstd stats which is helpful for testing time; we still run lz4/zstd on raw data but do not collect the summary statistics, as this is mostly useful when analyzing individual files. Also clean up output in -test mode to avoid printing dummy values.
1 parent 46a2407 commit 8e716e4

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

tools/codectest.cpp

+25-30
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,14 @@ size_t measure_zstd(const std::vector<unsigned char>& data)
5050
struct Stats
5151
{
5252
bool testz;
53-
double v10_raw;
54-
double v10_lz4;
55-
double v10_zstd;
5653
double count;
54+
double size;
5755

5856
double ratio_v0;
5957
double ratio_v1;
6058
double ratio_v1_lz4;
6159
double ratio_v1_zstd;
6260

63-
double total_src;
6461
double total_v0;
6562
double total_v1;
6663
double total_v1_lz4;
@@ -97,16 +94,14 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
9794
output.resize(meshopt_encodeVertexBufferLevel(output.data(), output.size(), decoded.data(), count, stride, level));
9895

9996
printf(" raw %zu KB\t", decoded.size() / 1024);
100-
printf(" v0 %.2f", double(input.size()) / double(decoded.size()));
101-
printf(" v1 %.2f", double(output.size()) / double(decoded.size()));
102-
printf(" v1/v0 %+.1f%%", double(output.size()) / double(input.size()) * 100 - 100);
97+
printf(" v0 %.3f", double(input.size()) / double(decoded.size()));
98+
printf(" v1 %.3f", double(output.size()) / double(decoded.size()));
10399

104100
if (stats)
105101
{
106-
stats->v10_raw += double(output.size()) / double(input.size()) - 1;
107102
stats->count++;
103+
stats->size += double(decoded.size());
108104

109-
stats->total_src += double(decoded.size());
110105
stats->total_v0 += double(input.size());
111106
stats->total_v1 += double(output.size());
112107

@@ -117,10 +112,8 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
117112
if (stats && stats->testz)
118113
{
119114
size_t decoded_lz4 = measure_lz4(decoded);
120-
size_t input_lz4 = measure_lz4(input);
121115
size_t output_lz4 = measure_lz4(output);
122116
size_t decoded_zstd = measure_zstd(decoded);
123-
size_t input_zstd = measure_zstd(input);
124117
size_t output_zstd = measure_zstd(output);
125118

126119
stats->total_v1_lz4 += output_lz4;
@@ -129,18 +122,11 @@ void testFile(FILE* file, size_t count, size_t stride, int level, Stats* stats =
129122
stats->ratio_v1_lz4 += log(double(output_lz4) / double(decoded.size()));
130123
stats->ratio_v1_zstd += log(double(output_zstd) / double(decoded.size()));
131124

132-
printf("\tlz4 %.2f:", double(decoded_lz4) / double(decoded.size()));
133-
printf(" v0 %.2f", double(input_lz4) / double(decoded.size()));
134-
printf(" v1 %.2f", double(output_lz4) / double(decoded.size()));
135-
printf(" v1/v0 %+.1f%%", double(output_lz4) / double(input_lz4) * 100 - 100);
125+
printf("\tlz4 %.3f", double(decoded_lz4) / double(decoded.size()));
126+
printf(" v1+lz4 %.3f", double(output_lz4) / double(decoded.size()));
136127

137-
printf("\tzstd %.2f:", double(decoded_zstd) / double(decoded.size()));
138-
printf(" v0 %.2f", double(input_zstd) / double(decoded.size()));
139-
printf(" v1 %.2f", double(output_zstd) / double(decoded.size()));
140-
printf(" v1/v0 %+.1f%%", double(output_zstd) / double(input_zstd) * 100 - 100);
141-
142-
stats->v10_lz4 += double(output_lz4) / double(input_lz4) - 1;
143-
stats->v10_zstd += double(output_zstd) / double(input_zstd) - 1;
128+
printf("\tzstd %.3f", double(decoded_zstd) / double(decoded.size()));
129+
printf(" v1+zstd %.3f", double(output_zstd) / double(decoded.size()));
144130
}
145131
}
146132

@@ -191,15 +177,24 @@ int main(int argc, char** argv)
191177
level = atoi(argv[2] + 1);
192178
for (int i = level < 0 ? 2 : 3; i < argc; ++i)
193179
testFile(argv[i], level < 0 ? 2 : level, &stats);
180+
194181
printf("---\n");
195-
printf("%d files: raw v1/v0 %+.2f%%, lz4 v1/v0 %+.2f%%, zstd v1/v0 %+.2f%%\n",
196-
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));
200-
printf("total: input %.2f MB, v0 %.2f MB, v1 %.2f MB, v1+lz4 %.2f MB, v1+zstd %.2f MB\n",
201-
stats.total_src / 1024 / 1024, stats.total_v0 / 1024 / 1024, stats.total_v1 / 1024 / 1024,
202-
stats.total_v1_lz4 / 1024 / 1024, stats.total_v1_zstd / 1024 / 1024);
182+
printf("%d files: v0 %.3f, v1 %.3f",
183+
int(stats.count),
184+
exp(stats.ratio_v0 / stats.count), exp(stats.ratio_v1 / stats.count));
185+
if (stats.testz)
186+
printf(", v1+lz4 %.3f, v1+zstd %.3f\n", exp(stats.ratio_v1_lz4 / stats.count), exp(stats.ratio_v1_zstd / stats.count));
187+
else
188+
printf("\n");
189+
190+
printf("total: %d files, raw %.2f MB, v0 %.2f MB, v1 %.2f MB",
191+
int(stats.count),
192+
stats.size / 1024 / 1024, stats.total_v0 / 1024 / 1024, stats.total_v1 / 1024 / 1024);
193+
if (stats.testz)
194+
printf(", v1+lz4 %.2f MB, v1+zstd %.2f MB\n", stats.total_v1_lz4 / 1024 / 1024, stats.total_v1_zstd / 1024 / 1024);
195+
else
196+
printf("\n");
197+
203198
return 0;
204199
}
205200

0 commit comments

Comments
 (0)