summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--programs/bench.c2
-rw-r--r--programs/lz4.1.md7
-rw-r--r--programs/lz4cli.c35
-rw-r--r--tests/Makefile6
4 files changed, 48 insertions, 2 deletions
diff --git a/programs/bench.c b/programs/bench.c
index 770191c..c91ce7c 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -407,7 +407,7 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
if (g_displayLevel == 1 && !g_additionalParam)
DISPLAY("bench %s %s: input %u bytes, %u seconds, %u KB blocks\n", LZ4_VERSION_STRING, LZ4_GIT_COMMIT_STRING, (U32)benchedSize, g_nbSeconds, (U32)(g_blockSize>>10));
- if (cLevelLast < cLevel) cLevelLast = cLevel;
+ // if (cLevelLast < cLevel) cLevelLast = cLevel;
for (l=cLevel; l <= cLevelLast; l++) {
BMK_benchMem(srcBuffer, benchedSize,
diff --git a/programs/lz4.1.md b/programs/lz4.1.md
index a5168e9..d4eaf8a 100644
--- a/programs/lz4.1.md
+++ b/programs/lz4.1.md
@@ -156,6 +156,13 @@ only the latest one will be applied.
* `-BD`:
Block Dependency (improves compression ratio on small blocks)
+* `--fast[=#]`:
+ switch to ultra-fast compression levels.
+ If `=#` is not present, it defaults to `1`.
+ The higher the value, the faster the compression speed, at the cost of some compression ratio.
+ This setting overwrites compression level if one was set previously.
+ Similarly, if a compression level is set after `--fast`, it overrides it.
+
* `--[no-]frame-crc`:
Select frame checksum (default:enabled)
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index ba519b4..94e3b14 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -141,6 +141,7 @@ static int usage_advanced(const char* exeName)
DISPLAY( "--content-size : compressed frame includes original size (default:not present)\n");
DISPLAY( "--[no-]sparse : sparse mode (default:enabled on file, disabled on stdout)\n");
DISPLAY( "--favor-decSpeed: compressed files decompress faster, but are less compressed \n");
+ DISPLAY( "--fast[=#]: switch to ultra fast compression level (default: %u)\n", 1);
DISPLAY( "Benchmark arguments : \n");
DISPLAY( " -b# : benchmark file(s), using # compression level (default : 1) \n");
DISPLAY( " -e# : test all compression levels from -bX to # (default : 1)\n");
@@ -272,13 +273,28 @@ static unsigned readU32FromChar(const char** stringPtr)
return result;
}
+/** longCommandWArg() :
+ * check if *stringPtr is the same as longCommand.
+ * If yes, @return 1 and advances *stringPtr to the position which immediately follows longCommand.
+ * @return 0 and doesn't modify *stringPtr otherwise.
+ */
+static unsigned longCommandWArg(const char** stringPtr, const char* longCommand)
+{
+ size_t const comSize = strlen(longCommand);
+ int const result = !strncmp(*stringPtr, longCommand, comSize);
+ if (result) *stringPtr += comSize;
+ return result;
+}
+
typedef enum { om_auto, om_compress, om_decompress, om_test, om_bench } operationMode_e;
+#define CLEAN_RETURN(i) { operationResult = (i); goto _cleanup; }
+
int main(int argc, const char** argv)
{
int i,
cLevel=1,
- cLevelLast=1,
+ cLevelLast=-10000,
legacy_format=0,
forceStdout=0,
main_pause=0,
@@ -363,6 +379,23 @@ int main(int argc, const char** argv)
if (!strcmp(argument, "--help")) { usage_advanced(exeName); goto _cleanup; }
if (!strcmp(argument, "--keep")) { LZ4IO_setRemoveSrcFile(0); continue; } /* keep source file (default) */
if (!strcmp(argument, "--rm")) { LZ4IO_setRemoveSrcFile(1); continue; }
+ if (longCommandWArg(&argument, "--fast")) {
+ /* Parse optional window log */
+ if (*argument == '=') {
+ U32 fastLevel;
+ ++argument;
+ fastLevel = readU32FromChar(&argument);
+ if (fastLevel) {
+ cLevel = -(int)fastLevel;
+ }
+ } else if (*argument != 0) {
+ /* Invalid character following --fast */
+ CLEAN_RETURN(badusage(exeName));
+ } else {
+ cLevel = -1; /* default for --fast */
+ }
+ continue;
+ }
}
while (argument[1]!=0) {
diff --git a/tests/Makefile b/tests/Makefile
index ac86c3e..a133df1 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -262,8 +262,14 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat
cat tmp-tlb-hw >> tmp-tlb-hw.lz4
$(LZ4) -f tmp-tlb-hw.lz4 # uncompress valid frame followed by invalid data
$(LZ4) -BX tmp-tlb-hw -c -q | $(LZ4) -tv # test block checksum
+ ./datagen -g256KB > tmp-tlb-dg256k
+ test "$(shell lz4 -c --fast tmp-tlb-dg256k| wc -c)" -lt "$(shell lz4 -c --fast=9 tmp-tlb-dg256k| wc -c)"
+ test "$(shell lz4 -c --fast=1 tmp-tlb-dg256k| wc -c)" -eq "$(shell lz4 -c --fast tmp-tlb-dg256k| wc -c)"
+ test "$(shell lz4 -c -9 tmp-tlb-dg256k| wc -c)" -lt "$(shell lz4 -c --fast=1 tmp-tlb-dg256k| wc -c)"
@$(RM) tmp-tlb*
+
+
test-lz4-dict: lz4 datagen
@echo "\n ---- test lz4 compression/decompression with dictionary ----"
./datagen -g16KB > tmp-dict