From 1faa7e2698e73864aa20729caba8071148af5b4c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 19 Mar 2018 17:19:25 -0700 Subject: [PATCH] bench: introduced hidden command -S to benchmark multiple files with separate results --- programs/bench.c | 34 +++++++++++++++++++++++++++------- programs/bench.h | 5 +++-- programs/lz4cli.c | 10 +++++++--- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/programs/bench.c b/programs/bench.c index 002eac9..770191c 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -119,21 +119,21 @@ static clock_t g_time = 0; static U32 g_nbSeconds = NBSECONDS; static size_t g_blockSize = 0; int g_additionalParam = 0; +int g_benchSeparately = 0; void BMK_setNotificationLevel(unsigned level) { g_displayLevel=level; } void BMK_setAdditionalParam(int additionalParam) { g_additionalParam=additionalParam; } -void BMK_SetNbSeconds(unsigned nbSeconds) +void BMK_setNbSeconds(unsigned nbSeconds) { g_nbSeconds = nbSeconds; DISPLAYLEVEL(3, "- test >= %u seconds per compression / decompression -\n", g_nbSeconds); } -void BMK_SetBlockSize(size_t blockSize) -{ - g_blockSize = blockSize; -} +void BMK_setBlockSize(size_t blockSize) { g_blockSize = blockSize; } + +void BMK_setBenchSeparately(int separate) { g_benchSeparately = (separate!=0); } /* ******************************************************** @@ -515,6 +515,22 @@ static void BMK_syntheticTest(int cLevel, int cLevelLast, double compressibility } +int BMK_benchFilesSeparately(const char** fileNamesTable, unsigned nbFiles, + int cLevel, int cLevelLast) +{ + unsigned fileNb; + if (cLevel > LZ4HC_CLEVEL_MAX) cLevel = LZ4HC_CLEVEL_MAX; + if (cLevelLast > LZ4HC_CLEVEL_MAX) cLevelLast = LZ4HC_CLEVEL_MAX; + if (cLevelLast < cLevel) cLevelLast = cLevel; + if (cLevelLast > cLevel) DISPLAYLEVEL(2, "Benchmarking levels from %d to %d\n", cLevel, cLevelLast); + + for (fileNb=0; fileNb>10)); } else { if (B < 32) badusage(exeName); - BMK_SetBlockSize(B); + BMK_setBlockSize(B); if (B >= 1024) { DISPLAYLEVEL(2, "bench: using blocks of size %u KB \n", (U32)(B>>10)); } else { @@ -480,6 +480,10 @@ int main(int argc, const char** argv) case 'b': mode = om_bench; multiple_inputs=1; break; + /* hidden command : benchmark files, but do not fuse result */ + case 'S': BMK_setBenchSeparately(1); + break; + #ifdef UTIL_HAS_CREATEFILELIST /* recursive */ case 'r': recursive=1; @@ -496,7 +500,7 @@ int main(int argc, const char** argv) iters = readU32FromChar(&argument); argument--; BMK_setNotificationLevel(displayLevel); - BMK_SetNbSeconds(iters); /* notification if displayLevel >= 3 */ + BMK_setNbSeconds(iters); /* notification if displayLevel >= 3 */ } break;