]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
removed pretty-print of sizes in benchmark
authorYann Collet <yann.collet.73@gmail.com>
Fri, 3 Sep 2021 19:51:02 +0000 (12:51 -0700)
committerYann Collet <yann.collet.73@gmail.com>
Fri, 3 Sep 2021 19:51:02 +0000 (12:51 -0700)
This is less appropriate for this mode :
benchmark is about accuracy,
it's important to read the exact values.

lib/compress/zstd_opt.c
programs/benchzstd.c
programs/util.c
programs/util.h

index 301f985cbfb6318a2704b35776200c86ff3508ca..c8d403cf5a6a2f2a1e7e24ad19d67524fa924fc0 100644 (file)
@@ -987,7 +987,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
              * in every price. We include the literal length to avoid negative
              * prices when we subtract the previous literal length.
              */
-            opt[0].price = ZSTD_litLengthPrice(litlen, optStatePtr, optLevel);
+            opt[0].price = (int)ZSTD_litLengthPrice(litlen, optStatePtr, optLevel);
 
             /* large match -> immediate encoding */
             {   U32 const maxML = matches[nbMatches-1].len;
@@ -1007,6 +1007,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
             }   }
 
             /* set prices for first matches starting position == 0 */
+            assert(opt[0].price >= 0);
             {   U32 const literalsPrice = opt[0].price + ZSTD_litLengthPrice(0, optStatePtr, optLevel);
                 U32 pos;
                 U32 matchNb;
index 32ce605930e24012cec0b951ccda852167e6b298..262efb1b12cebbd765ba6d9dc28f149de983862d 100644 (file)
@@ -181,7 +181,7 @@ BMK_initCCtx(ZSTD_CCtx* ctx,
     CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_minMatch, (int)comprParams->minMatch));
     CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_targetLength, (int)comprParams->targetLength));
     CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_literalCompressionMode, (int)adv->literalCompressionMode));
-    CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_strategy, comprParams->strategy));
+    CHECK_Z(ZSTD_CCtx_setParameter(ctx, ZSTD_c_strategy, (int)comprParams->strategy));
     CHECK_Z(ZSTD_CCtx_loadDictionary(ctx, dictBuffer, dictBufferSize));
 }
 
@@ -393,8 +393,6 @@ BMK_benchMemAdvancedNoAlloc(
         BMK_benchParams_t cbp, dbp;
         BMK_initCCtxArgs cctxprep;
         BMK_initDCtxArgs dctxprep;
-        UTIL_HumanReadableSize_t hr_isize;
-        UTIL_HumanReadableSize_t hr_osize;
 
         cbp.benchFn = local_defaultCompress;   /* ZSTD_compress2 */
         cbp.benchPayload = cctx;
@@ -431,10 +429,9 @@ BMK_benchMemAdvancedNoAlloc(
         dctxprep.dictBuffer = dictBuffer;
         dctxprep.dictBufferSize = dictBufferSize;
 
-        hr_isize = UTIL_makeHumanReadableSize((U64) srcSize);
-
         DISPLAYLEVEL(2, "\r%70s\r", "");   /* blank line */
-        DISPLAYLEVEL(2, "%2s-%-17.17s : %.*f%s -> \r", marks[markNb], displayName, hr_isize.precision, hr_isize.value, hr_isize.suffix);
+        assert(srcSize < UINT_MAX);
+        DISPLAYLEVEL(2, "%2s-%-17.17s :%10u -> \r", marks[markNb], displayName, (unsigned)srcSize);
 
         while (!(compressionCompleted && decompressionCompleted)) {
             if (!compressionCompleted) {
@@ -446,7 +443,7 @@ BMK_benchMemAdvancedNoAlloc(
 
                 {   BMK_runTime_t const cResult = BMK_extract_runTime(cOutcome);
                     cSize = cResult.sumOfReturn;
-                    ratio = (double)srcSize / cSize;
+                    ratio = (double)srcSize / (double)cSize;
                     {   BMK_benchResult_t newResult;
                         newResult.cSpeed = (U64)((double)srcSize * TIMELOOP_NANOSEC / cResult.nanoSecPerRun);
                         benchResult.cSize = cSize;
@@ -455,11 +452,10 @@ BMK_benchMemAdvancedNoAlloc(
                 }   }
 
                 {   int const ratioAccuracy = (ratio < 10.) ? 3 : 2;
-                    hr_osize = UTIL_makeHumanReadableSize((U64) cSize);
-                    DISPLAYLEVEL(2, "%2s-%-17.17s : %.*f%s -> %.*f%s (%5.*f), %6.*f MB/s\r",
+                    assert(cSize < UINT_MAX);
+                    DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.*f), %6.*f MB/s\r",
                             marks[markNb], displayName,
-                            hr_isize.precision, hr_isize.value, hr_isize.suffix,
-                            hr_osize.precision, hr_osize.value, hr_osize.suffix,
+                            (unsigned)srcSize, (unsigned)cSize,
                             ratioAccuracy, ratio,
                             benchResult.cSpeed < (10 MB) ? 2 : 1, (double)benchResult.cSpeed / MB_UNIT);
                 }
@@ -480,11 +476,9 @@ BMK_benchMemAdvancedNoAlloc(
                 }
 
                 {   int const ratioAccuracy = (ratio < 10.) ? 3 : 2;
-                    hr_osize = UTIL_makeHumanReadableSize((U64) cSize);
-                    DISPLAYLEVEL(2, "%2s-%-17.17s : %.*f%s -> %.*f%s (%5.*f), %6.*f MB/s, %6.1f MB/s \r",
+                    DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.*f), %6.*f MB/s, %6.1f MB/s \r",
                             marks[markNb], displayName,
-                            hr_isize.precision, hr_isize.value, hr_isize.suffix,
-                            hr_osize.precision, hr_osize.value, hr_osize.suffix,
+                            (unsigned)srcSize, (unsigned)cSize,
                             ratioAccuracy, ratio,
                             benchResult.cSpeed < (10 MB) ? 2 : 1, (double)benchResult.cSpeed / MB_UNIT,
                             (double)benchResult.dSpeed / MB_UNIT);
index b29177818b8b569c10b9c43b140edee7edff52e6..61cde727e0106df6fd04410a904f205af517a16f 100644 (file)
@@ -308,7 +308,8 @@ U64 UTIL_getFileSizeStat(const stat_t* statbuf)
     return (U64)statbuf->st_size;
 }
 
-UTIL_HumanReadableSize_t UTIL_makeHumanReadableSize(U64 size) {
+UTIL_HumanReadableSize_t UTIL_makeHumanReadableSize(U64 size)
+{
     UTIL_HumanReadableSize_t hrs;
 
     if (g_utilDisplayLevel > 3) {
@@ -1121,9 +1122,9 @@ DWORD CountSetBits(ULONG_PTR bitMask)
 {
     DWORD LSHIFT = sizeof(ULONG_PTR)*8 - 1;
     DWORD bitSetCount = 0;
-    ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT;    
+    ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT;
     DWORD i;
-    
+
     for (i = 0; i <= LSHIFT; ++i)
     {
         bitSetCount += ((bitMask & bitTest)?1:0);
index 7632b9a0a66fc73a6a6720b5516bbb4c828f1913..5e529b7ebaee80c36cd98ca396be90d578d23e22 100644 (file)
@@ -180,9 +180,13 @@ U64 UTIL_getFileSize(const char* infilename);
 U64 UTIL_getTotalFileSize(const char* const * fileNamesTable, unsigned nbFiles);
 
 /**
- * Take a size in bytes and prepare the components to pretty-print it in a
- * scaled way. The components in the returned struct should be passed in
+ * Take @size in bytes,
+ * prepare the components to pretty-print it in a scaled way.
+ * The components in the returned struct should be passed in
  * precision, value, suffix order to a "%.*f%s" format string.
+ * Output policy is sensible to @g_utilDisplayLevel,
+ * for verbose mode (@g_utilDisplayLevel >= 4),
+ * does not scale down.
  */
 typedef struct {
   double value;