From a4aa9ab246613323fb5344c52bc921ed5a832c9f Mon Sep 17 00:00:00 2001 From: janwas Date: Fri, 18 Mar 2005 22:18:34 +0000 Subject: [PATCH] zip: add instrumentation, see how much time decompression takes This was SVN commit r2011. --- source/lib/res/zip.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/lib/res/zip.cpp b/source/lib/res/zip.cpp index 9ea61a8c29..39bc3a3f3e 100755 --- a/source/lib/res/zip.cpp +++ b/source/lib/res/zip.cpp @@ -39,6 +39,8 @@ #include "res.h" #include "byte_order.h" +#include "timer.h" + #include #include @@ -803,6 +805,13 @@ int inf_set_dest(uintptr_t _ctx, void* out, size_t out_size) #endif } +static double total_inf_time; + +static void dump() +{ + debug_out("TOTAL INFLATE TIME: %g\n", total_inf_time); +} + // unzip into output buffer. returns bytes written // (may be 0, if not enough data is passed in), or < 0 on error. @@ -811,6 +820,10 @@ ssize_t inf_inflate(uintptr_t _ctx, void* in, size_t in_size, bool free_in_buf = #ifdef NO_ZLIB return -1; #else + +ONCE(atexit(dump)); +double t0 = get_time(); + InfCtx* ctx = (InfCtx*)_ctx; z_stream* zs = &ctx->zs; @@ -844,6 +857,9 @@ ssize_t inf_inflate(uintptr_t _ctx, void* in, size_t in_size, bool free_in_buf = zs->total_out += size; } +double t1 = get_time(); +total_inf_time += t1-t0; + // check+return how much actual data was read // // note: zlib may not always output data, e.g. if passed very little