diff options
author | Reto Koradi <reto@fb.com> | 2019-11-04 19:51:41 (GMT) |
---|---|---|
committer | Reto Koradi <reto@fb.com> | 2019-11-06 07:38:00 (GMT) |
commit | cc91777c98d71194c9d29544f84880742ffdf86c (patch) | |
tree | a292c1082221dcf05549d1a88a3b6c36c93186d9 /programs/lz4cli.c | |
parent | e8baeca51ef2003d6c9ec21c32f1563fef1065b9 (diff) | |
download | lz4-cc91777c98d71194c9d29544f84880742ffdf86c.zip lz4-cc91777c98d71194c9d29544f84880742ffdf86c.tar.gz lz4-cc91777c98d71194c9d29544f84880742ffdf86c.tar.bz2 |
Make benchmark compatible with dictionary compression
Support the -D command line option for running benchmarks. The
benchmark code was slightly restructured to factor out the calls
that need to be different for each benchmark scenario. Since there
are now 4 scenarios (all combinations of fast/HC and with/without
dictionary), the logic was getting somewhat convoluted otherwise.
This was done by extending the compressionParameters struct that
previously contained just a single function pointer. It now
contains 4 function pointers for init/reset/compress/cleanup,
with the related state. The functions get a pointer to the
structure as their first argument (inspired by C++), so that they
can access the state values in the struct.
Diffstat (limited to 'programs/lz4cli.c')
-rw-r--r-- | programs/lz4cli.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 5da7654..e95050b 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -625,10 +625,18 @@ int main(int argc, const char** argv) #endif } + if (dictionary_filename) { + if (!strcmp(dictionary_filename, stdinmark) && IS_CONSOLE(stdin)) { + DISPLAYLEVEL(1, "refusing to read from a console\n"); + exit(1); + } + LZ4IO_setDictionaryFilename(prefs, dictionary_filename); + } + /* benchmark and test modes */ if (mode == om_bench) { BMK_setNotificationLevel(displayLevel); - operationResult = BMK_benchFiles(inFileNames, ifnIdx, cLevel, cLevelLast); + operationResult = BMK_benchFiles(inFileNames, ifnIdx, cLevel, cLevelLast, dictionary_filename); goto _cleanup; } @@ -638,14 +646,6 @@ int main(int argc, const char** argv) mode = om_decompress; /* defer to decompress */ } - if (dictionary_filename) { - if (!strcmp(dictionary_filename, stdinmark) && IS_CONSOLE(stdin)) { - DISPLAYLEVEL(1, "refusing to read from a console\n"); - exit(1); - } - LZ4IO_setDictionaryFilename(prefs, dictionary_filename); - } - /* compress or decompress */ if (!input_filename) input_filename = stdinmark; /* Check if input is defined as console; trigger an error in this case */ |