]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
bench.c: fixed rare compression and decompression speed bug
authorinikep <inikep@gmail.com>
Fri, 15 Apr 2016 14:54:11 +0000 (16:54 +0200)
committerinikep <inikep@gmail.com>
Fri, 15 Apr 2016 14:54:11 +0000 (16:54 +0200)
concerns only big files with compression or decompression time longer
than 100 seconds

programs/bench.c

index 4da51f6377c18fa04836c55eef7ceda70bc01279..de9e16e95e63d21bf8b41ce3110527e986b612a9 100644 (file)
@@ -295,7 +295,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
     RDG_genBuffer(compressedBuffer, maxCompressedSize, 0.10, 0.50, 1);
 
     /* Bench */
-    {   double fastestC = 100000000., fastestD = 100000000.;
+    {   U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
         U64 const crcOrig = XXH64(srcBuffer, srcSize, 0);
         U64 crcCheck = 0;
         BMK_time_t coolTime;
@@ -344,7 +344,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
                         blockTable[blockNb].cSize = rSize;
                 }   }
                 {   U64 const clockSpan = BMK_clockSpan(clockStart, ticksPerSecond);
-                    if ((double)clockSpan < fastestC*nbLoops) fastestC = (double)clockSpan / nbLoops;
+                    if (clockSpan < fastestC*nbLoops) fastestC = clockSpan / nbLoops;
             }   }
 
             cSize = 0;
@@ -382,7 +382,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
                         blockTable[blockNb].resSize = regenSize;
                 }   }
                 {   U64 const clockSpan = BMK_clockSpan(clockStart, ticksPerSecond);
-                    if ((double)clockSpan < fastestD*nbLoops) fastestD = (double)clockSpan / nbLoops;
+                    if (clockSpan < fastestD*nbLoops) fastestD = clockSpan / nbLoops;
             }   }
 
             DISPLAYLEVEL(2, "%2i-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s ,%6.1f MB/s\r",