deflatehd: Print overall input, output length and compression ratio
This commit is contained in:
parent
53b3fba05b
commit
b71bb6dcd9
|
@ -47,6 +47,9 @@ typedef struct {
|
||||||
|
|
||||||
static deflate_config config;
|
static deflate_config config;
|
||||||
|
|
||||||
|
static size_t input_sum;
|
||||||
|
static size_t output_sum;
|
||||||
|
|
||||||
static void to_hex(char *dest, const uint8_t *src, size_t len)
|
static void to_hex(char *dest, const uint8_t *src, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -94,6 +97,8 @@ static void deflate_hd(nghttp2_hd_context *deflater,
|
||||||
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
|
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
input_sum += inputlen;
|
||||||
|
output_sum += rv;
|
||||||
output_to_json(deflater, buf, rv, inputlen, seq);
|
output_to_json(deflater, buf, rv, inputlen, seq);
|
||||||
nghttp2_hd_end_headers(deflater);
|
nghttp2_hd_end_headers(deflater);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -379,6 +384,8 @@ int main(int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
perform(&deflater);
|
perform(&deflater);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "Overall: input=%zu output=%zu ratio=%.02f\n",
|
||||||
|
input_sum, output_sum, (double)output_sum / input_sum);
|
||||||
nghttp2_hd_deflate_free(&deflater);
|
nghttp2_hd_deflate_free(&deflater);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue