aboutsummaryrefslogtreecommitdiff
path: root/c/tools/brotli.c
diff options
context:
space:
mode:
authorPavel Rosický <pdahorek@seznam.cz>2020-09-07 10:53:03 +0200
committerGitHub <noreply@github.com>2020-09-07 10:53:03 +0200
commit90fd2b60cc24e03224bdf1843e4181e985800218 (patch)
tree0f59545c66d10a08d4aa4d5615481c6e3093ab04 /c/tools/brotli.c
parent7e8e207ce22a8eb6ce0148015fe3f560ac1e48b5 (diff)
downloadbrotli-90fd2b60cc24e03224bdf1843e4181e985800218.zip
brotli-90fd2b60cc24e03224bdf1843e4181e985800218.tar.gz
brotli-90fd2b60cc24e03224bdf1843e4181e985800218.tar.bz2
add execution time (#834)
Diffstat (limited to 'c/tools/brotli.c')
-rw-r--r--c/tools/brotli.c8
1 files changed, 8 insertions, 0 deletions
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 @@ typedef struct {
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 @@ static void InitializeBuffers(Context* context) {
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 @@ static void PrintFileProcessingProgress(Context* context) {
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 @@ static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {
return BROTLI_FALSE;
}
if (context->verbosity > 0) {
+ context->end_time = clock();
fprintf(stderr, "Decompressed ");
PrintFileProcessingProgress(context);
fprintf(stderr, "\n");
@@ -966,6 +973,7 @@ static BROTLI_BOOL CompressFile(Context* context, BrotliEncoderState* s) {
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");