From: Yann Collet Date: Wed, 21 Feb 2018 15:30:26 +0000 (-0800) Subject: update fullbench measurement methodology X-Git-Tag: v1.3.4~1^2~51^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=364ce19463c42a651438fd63ded8c0d50a7d6f98;p=thirdparty%2Fzstd.git update fullbench measurement methodology to use less calls to time(), like bench.c. also upgraded accuracy to nanosecond. --- diff --git a/tests/fullbench.c b/tests/fullbench.c index 199f4966b..6a4084940 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -413,33 +413,48 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb) break; /* test functions */ - /* by convention, test functions can be added > 100 */ + /* convention: test functions have ID > 100 */ default : ; } - { size_t i; for (i=0; i %s !! \n", benchName, ZSTD_getErrorName(benchResult)); exit(1); } - } - { U64 const clockSpanMicro = UTIL_clockSpanMicro(clockStart); - double const averageTime = (double)clockSpanMicro / TIME_SEC_MICROSEC / nbRounds; - if (averageTime < bestTime) bestTime = averageTime; - DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", loopNb, benchName, (double)srcSize / (1 MB) / bestTime, (U32)benchResult); + if (ZSTD_isError(benchResult)) { + DISPLAY("ERROR ! %s() => %s !! \n", benchName, ZSTD_getErrorName(benchResult)); + exit(1); + } } + { U64 const clockSpanNano = UTIL_clockSpanNano(clockStart); + double const averageTime = (double)clockSpanNano / TIME_SEC_NANOSEC / nbRounds; + if (clockSpanNano > 0) { + if (averageTime < bestTime) bestTime = averageTime; + assert(bestTime > (1./2000000000)); + nbRounds = (U32)(1. / bestTime); /* aim for 1 sec */ + DISPLAY("%2i- %-30.30s : %7.1f MB/s (%9u)\r", + loopNb, benchName, + (double)srcSize / (1 MB) / bestTime, + (U32)benchResult); + } else { + assert(nbRounds < 40000000); /* avoid overflow */ + nbRounds *= 100; + } } } } DISPLAY("%2u\n", benchNb); @@ -573,7 +588,7 @@ int main(int argc, const char** argv) for(i=1; i