]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add compressed and ratio fields to deflate/corpora benchmarks
authorNathan Moin Vaziri <nathan@nathanm.com>
Mon, 13 Apr 2026 05:27:42 +0000 (22:27 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 24 Apr 2026 10:15:32 +0000 (12:15 +0200)
test/benchmarks/benchmark_corpora.cc
test/benchmarks/benchmark_deflate.cc

index 19eaeea6c0f74a60572b8e587a5e1f3d8c05ef48..135ee98c9958d0a3fd64083650e75f83a1d7307c 100644 (file)
@@ -189,7 +189,7 @@ public:
         if (!load_corpus_file(cf))
             return;
 
-        outbuff_size = PREFIX(deflateBound)(NULL, (z_uintmax_t)cf->size);
+        outbuff_size = PREFIX(deflateBound)(NULL, (unsigned long)cf->size);
         outbuff = (uint8_t *)malloc(outbuff_size);
         if (outbuff == NULL)
             return;
@@ -225,6 +225,9 @@ public:
                 break;
             }
         }
+
+        state.counters["compressed"] = benchmark::Counter(double(strm.total_out));
+        state.counters["ratio"] = benchmark::Counter(double(cf->size) / double(strm.total_out));
     }
 
     void TearDown(const benchmark::State &) override {
@@ -259,7 +262,7 @@ public:
         outbuff = (uint8_t *)malloc(cf->size);
 
         /* Pre-compress the file for inflate benchmarking */
-        z_uintmax_t comp_bound = PREFIX(deflateBound)(NULL, (z_uintmax_t)cf->size);
+        z_uintmax_t comp_bound = PREFIX(deflateBound)(NULL, (unsigned long)cf->size);
         compressed = (uint8_t *)malloc(comp_bound);
 
         if (compressed != NULL) {
@@ -312,6 +315,9 @@ public:
                 break;
             }
         }
+
+        state.counters["compressed"] = benchmark::Counter(double(strm.total_out));
+        state.counters["ratio"] = benchmark::Counter(double(cf->size) / double(strm.total_out));
     }
 
     void TearDown(const benchmark::State &) override {
@@ -330,7 +336,7 @@ static int register_corpora_benchmarks(void) {
     if (!discover_corpora())
         return 0;
 
-    int levels[] = {1, 6, 9};
+    int levels[] = {1, 3, 6, 8, 9};
 
     size_t prefix_len = strlen(CORPORA_DIR) + 1;
 
index f60e2589d10cccae0646d4bfb89f8ea92940d2d1..0f6e5e693a5ac597964d0dfb12990079044c459b 100644 (file)
@@ -91,6 +91,9 @@ public:
             state.SkipWithError("deflateEnd did not return Z_OK");
             return;
         }
+
+        state.counters["compressed"] = benchmark::Counter(double(strm.total_out));
+        state.counters["ratio"] = benchmark::Counter(double(size) / double(strm.total_out));
     }
 
     void TearDown(const ::benchmark::State&) {