add execution time (#834)
diff --git a/c/tools/brotli.c b/c/tools/brotli.c
index 7c678d3..77752b2 100644
--- a/c/tools/brotli.c
+++ b/c/tools/brotli.c
@@ -132,6 +132,8 @@
until 4GiB+ files are compressed / decompressed on 32-bit CPUs. */
size_t total_in;
size_t total_out;
+ clock_t start_time;
+ clock_t end_time;
} Context;
/* Parse up to 5 decimal digits. */
@@ -806,6 +808,9 @@
context->next_out = context->output;
context->total_in = 0;
context->total_out = 0;
+ if (context->verbosity > 0) {
+ context->start_time = clock();
+ }
}
/* This method might give the false-negative result.
@@ -873,6 +878,7 @@
PrintBytes(context->total_in);
fprintf(stderr, " -> ");
PrintBytes(context->total_out);
+ fprintf(stderr, " in %1.2f sec", (double)(context->end_time - context->start_time) / CLOCKS_PER_SEC);
}
static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {
@@ -898,6 +904,7 @@
return BROTLI_FALSE;
}
if (context->verbosity > 0) {
+ context->end_time = clock();
fprintf(stderr, "Decompressed ");
PrintFileProcessingProgress(context);
fprintf(stderr, "\n");
@@ -966,6 +973,7 @@
if (BrotliEncoderIsFinished(s)) {
if (!FlushOutput(context)) return BROTLI_FALSE;
if (context->verbosity > 0) {
+ context->end_time = clock();
fprintf(stderr, "Compressed ");
PrintFileProcessingProgress(context);
fprintf(stderr, "\n");