summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHamid Zare <dellydela@gmail.com>2019-07-11 14:39:29 -0700
committerHamid Zare <dellydela@gmail.com>2019-07-11 14:39:29 -0700
commit771a7192d6aa46e5c136ded366a216af60df3583 (patch)
treeca3a8e2f487f1889ca81d48a6295cdf95edba82a /examples
parent658ab8fca1c7bbc191d63c17ee751344a591f3ce (diff)
downloadlz4-771a7192d6aa46e5c136ded366a216af60df3583.tar.gz
lz4-771a7192d6aa46e5c136ded366a216af60df3583.tar.bz2
lz4-771a7192d6aa46e5c136ded366a216af60df3583.zip
print the compression ratio
Diffstat (limited to 'examples')
-rw-r--r--examples/simple_buffer.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/simple_buffer.c b/examples/simple_buffer.c
index 62409d0..ea57022 100644
--- a/examples/simple_buffer.c
+++ b/examples/simple_buffer.c
@@ -55,7 +55,8 @@ int main(void) {
if (compressed_data_size <= 0)
run_screaming("A 0 or negative result from LZ4_compress_default() indicates a failure trying to compress the data. ", 1);
if (compressed_data_size > 0)
- printf("We successfully compressed some data!\n");
+ printf("We successfully compressed some data! Ratio: %.2f\n",
+ (float) compressed_data_size/src_size);
// Not only does a positive return_value mean success, the value returned == the number of bytes required.
// You can use this to realloc() *compress_data to free up memory, if desired. We'll do so just to demonstrate the concept.
compressed_data = (char *)realloc(compressed_data, (size_t)compressed_data_size);