From 1a233c5f0fb665fa6b65c856b150bdef92654b42 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 20 Feb 2018 11:37:19 -0800 Subject: update bench.c to use less time invocations translating into more accurate speed measurements for small sources --- programs/bench.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/programs/bench.c b/programs/bench.c index fac2a87..91292bc 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -41,6 +41,7 @@ #include /* memset */ #include /* fprintf, fopen, ftello */ #include /* clock_t, clock, CLOCKS_PER_SEC */ +#include /* assert */ #include "datagen.h" /* RDG_genBuffer */ #include "xxhash.h" @@ -219,6 +220,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, U64 const crcOrig = XXH64(srcBuffer, srcSize, 0); UTIL_time_t coolTime; U64 const maxTime = (g_nbSeconds * TIMELOOP_MICROSEC) + 100; + U32 nbDecodeLoops = ((200 MB) / (srcSize+1)) + 1; /* conservative decode speed estimate */ U64 totalCTime=0, totalDTime=0; U32 cCompleted=0, dCompleted=0; # define NB_MARKS 4 @@ -279,13 +281,13 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize, /* Decompression */ if (!dCompleted) memset(resultBuffer, 0xD6, srcSize); /* warm result buffer */ - UTIL_sleepMilli(1); /* give processor time to other processes */ + UTIL_sleepMilli(5); /* give processor time to other processes */ UTIL_waitForNextTick(); - clockStart = UTIL_getTime(); if (!dCompleted) { - U32 nbLoops = 0; - do { + U32 nbLoops; + clockStart = UTIL_getTime(); + for (nbLoops=0; nbLoops < nbDecodeLoops; nbLoops++) { U32 blockNb; for (blockNb=0; blockNb(DECOMP_MULT*maxTime); + dCompleted = totalDTime > (DECOMP_MULT*maxTime); } } markNb = (markNb+1) % NB_MARKS; -- cgit v0.12