From b19637c39aab1d51aa3103a3413a934ec5c331ab Mon Sep 17 00:00:00 2001 From: Devin Acker Date: Wed, 5 Jun 2013 19:14:09 -0400 Subject: [PATCH] add compression time, change ratio to percentage --- inhal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inhal.c b/inhal.c index a02b532..ec4dcc9 100644 --- a/inhal.c +++ b/inhal.c @@ -11,6 +11,7 @@ */ #include +#include #include "compress.h" int main (int argc, char **argv) { @@ -72,14 +73,18 @@ int main (int argc, char **argv) { fread(unpacked, sizeof(uint8_t), inputsize, infile); // compress the file + clock_t time = clock(); outputsize = pack(unpacked, inputsize, packed); + time = clock() - time; // write the compressed data to the file fseek(outfile, fileoffset, SEEK_SET); fwrite((const void*)packed, 1, outputsize, outfile); printf("Compressed size: %d bytes\n", outputsize); - printf("Compression ratio: %3.2f\n\n", (double)outputsize / inputsize); + printf("Compression ratio: %4.2f%%\n", 100 * (double)outputsize / inputsize); + printf("Compression time: %4.3f seconds\n\n", (double)time / CLOCKS_PER_SEC); + printf("Inserted at 0x%06X - 0x%06X\n", fileoffset, ftell(outfile) - 1); fclose(infile);