summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
Diffstat (limited to 'programs')
-rw-r--r--programs/Makefile62
-rw-r--r--programs/bench.c101
-rw-r--r--programs/bench.h5
-rw-r--r--programs/lz4.1.md6
-rw-r--r--programs/lz4cli.c12
-rw-r--r--programs/lz4io.c23
-rw-r--r--programs/lz4io.h7
-rw-r--r--programs/util.h20
8 files changed, 151 insertions, 85 deletions
diff --git a/programs/Makefile b/programs/Makefile
index a51bd4b..72bdcaa 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -120,21 +120,19 @@ lz4cat: lz4
DESTDIR ?=
# directory variables : GNU conventions prefer lowercase
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
-# support both lower and uppercase (BSD), use uppercase in script
-prefix ?= /usr/local
-PREFIX ?= $(prefix)
-exec_prefix ?= $(PREFIX)
-bindir ?= $(exec_prefix)/bin
-BINDIR ?= $(bindir)
-datarootdir ?= $(PREFIX)/share
-mandir ?= $(datarootdir)/man
-man1dir ?= $(mandir)/man1
-
-ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
-MANDIR ?= $(PREFIX)/man/man1
-else
-MANDIR ?= $(man1dir)
-endif
+# support both lower and uppercase (BSD), use lowercase in script
+PREFIX ?= /usr/local
+prefix ?= $(PREFIX)
+EXEC_PREFIX ?= $(prefix)
+exec_prefix ?= $(EXEC_PREFIX)
+BINDIR ?= $(exec_prefix)/bin
+bindir ?= $(BINDIR)
+DATAROOTDIR ?= $(prefix)/share
+datarootdir ?= $(DATAROOTDIR)
+MANDIR ?= $(datarootdir)/man
+mandir ?= $(MANDIR)
+MAN1DIR ?= $(mandir)/man1
+man1dir ?= $(MAN1DIR)
ifneq (,$(filter $(shell uname),SunOS))
INSTALL ?= ginstall
@@ -148,27 +146,27 @@ INSTALL_DATA ?= $(INSTALL) -m 644
install: lz4
@echo Installing binaries
- @$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
- @$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(BINDIR)/lz4
- @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4c
- @ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat
- @ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4
+ @$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/
+ @$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(bindir)/lz4
+ @ln -sf lz4 $(DESTDIR)$(bindir)/lz4c
+ @ln -sf lz4 $(DESTDIR)$(bindir)/lz4cat
+ @ln -sf lz4 $(DESTDIR)$(bindir)/unlz4
@echo Installing man pages
- @$(INSTALL_DATA) lz4.1 $(DESTDIR)$(MANDIR)/lz4.1
- @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4c.1
- @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4cat.1
- @ln -sf lz4.1 $(DESTDIR)$(MANDIR)/unlz4.1
+ @$(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1
+ @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4c.1
+ @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1
+ @ln -sf lz4.1 $(DESTDIR)$(man1dir)/unlz4.1
@echo lz4 installation completed
uninstall:
- @$(RM) $(DESTDIR)$(BINDIR)/lz4cat
- @$(RM) $(DESTDIR)$(BINDIR)/unlz4
- @$(RM) $(DESTDIR)$(BINDIR)/lz4
- @$(RM) $(DESTDIR)$(BINDIR)/lz4c
- @$(RM) $(DESTDIR)$(MANDIR)/lz4.1
- @$(RM) $(DESTDIR)$(MANDIR)/lz4c.1
- @$(RM) $(DESTDIR)$(MANDIR)/lz4cat.1
- @$(RM) $(DESTDIR)$(MANDIR)/unlz4.1
+ @$(RM) $(DESTDIR)$(bindir)/lz4cat
+ @$(RM) $(DESTDIR)$(bindir)/unlz4
+ @$(RM) $(DESTDIR)$(bindir)/lz4
+ @$(RM) $(DESTDIR)$(bindir)/lz4c
+ @$(RM) $(DESTDIR)$(man1dir)/lz4.1
+ @$(RM) $(DESTDIR)$(man1dir)/lz4c.1
+ @$(RM) $(DESTDIR)$(man1dir)/lz4cat.1
+ @$(RM) $(DESTDIR)$(man1dir)/unlz4.1
@echo lz4 programs successfully uninstalled
endif
diff --git a/programs/bench.c b/programs/bench.c
index fac2a87..770191c 100644
--- a/programs/bench.c
+++ b/programs/bench.c
@@ -41,6 +41,7 @@
#include <string.h> /* memset */
#include <stdio.h> /* fprintf, fopen, ftello */
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
+#include <assert.h> /* assert */
#include "datagen.h" /* RDG_genBuffer */
#include "xxhash.h"
@@ -66,6 +67,7 @@ static int LZ4_compress_local(const char* src, char* dst, int srcSize, int dstSi
#define NBSECONDS 3
#define TIMELOOP_MICROSEC 1*1000000ULL /* 1 second */
+#define TIMELOOP_NANOSEC 1*1000000000ULL /* 1 second */
#define ACTIVEPERIOD_MICROSEC 70*1000000ULL /* 70 seconds */
#define COOLPERIOD_SEC 10
#define DECOMP_MULT 1 /* test decompression DECOMP_MULT times longer than compression */
@@ -117,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); }
/* ********************************************************
@@ -218,7 +220,9 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
{ U64 fastestC = (U64)(-1LL), fastestD = (U64)(-1LL);
U64 const crcOrig = XXH64(srcBuffer, srcSize, 0);
UTIL_time_t coolTime;
- U64 const maxTime = (g_nbSeconds * TIMELOOP_MICROSEC) + 100;
+ U64 const maxTime = (g_nbSeconds * TIMELOOP_NANOSEC) + 100;
+ U32 nbCompressionLoops = (U32)((5 MB) / (srcSize+1)) + 1; /* conservative initial compression speed estimate */
+ U32 nbDecodeLoops = (U32)((200 MB) / (srcSize+1)) + 1; /* conservative initial decode speed estimate */
U64 totalCTime=0, totalDTime=0;
U32 cCompleted=0, dCompleted=0;
# define NB_MARKS 4
@@ -230,9 +234,6 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
coolTime = UTIL_getTime();
DISPLAYLEVEL(2, "\r%79s\r", "");
while (!cCompleted || !dCompleted) {
- UTIL_time_t clockStart;
- U64 clockLoop = g_nbSeconds ? TIMELOOP_MICROSEC : 1;
-
/* overheat protection */
if (UTIL_clockSpanMicro(coolTime) > ACTIVEPERIOD_MICROSEC) {
DISPLAYLEVEL(2, "\rcooling down ... \r");
@@ -246,21 +247,27 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
UTIL_sleepMilli(1); /* give processor time to other processes */
UTIL_waitForNextTick();
- clockStart = UTIL_getTime();
if (!cCompleted) { /* still some time to do compression tests */
- U32 nbLoops = 0;
- do {
+ UTIL_time_t const clockStart = UTIL_getTime();
+ U32 nbLoops;
+ for (nbLoops=0; nbLoops < nbCompressionLoops; nbLoops++) {
U32 blockNb;
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
size_t const rSize = compP.compressionFunction(blockTable[blockNb].srcPtr, blockTable[blockNb].cPtr, (int)blockTable[blockNb].srcSize, (int)blockTable[blockNb].cRoom, cLevel);
if (LZ4_isError(rSize)) EXM_THROW(1, "LZ4_compress() failed");
blockTable[blockNb].cSize = rSize;
+ } }
+ { U64 const clockSpan = UTIL_clockSpanNano(clockStart);
+ if (clockSpan > 0) {
+ if (clockSpan < fastestC * nbCompressionLoops)
+ fastestC = clockSpan / nbCompressionLoops;
+ assert(fastestC > 0);
+ nbCompressionLoops = (U32)(TIMELOOP_NANOSEC / fastestC) + 1; /* aim for ~1sec */
+ } else {
+ assert(nbCompressionLoops < 40000000); /* avoid overflow */
+ nbCompressionLoops *= 100;
}
- nbLoops++;
- } while (UTIL_clockSpanMicro(clockStart) < clockLoop);
- { U64 const clockSpan = UTIL_clockSpanMicro(clockStart);
- if (clockSpan < fastestC*nbLoops) fastestC = clockSpan / nbLoops;
totalCTime += clockSpan;
cCompleted = totalCTime>maxTime;
} }
@@ -272,44 +279,48 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
markNb = (markNb+1) % NB_MARKS;
DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s\r",
marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
- (double)srcSize / fastestC );
+ ((double)srcSize / fastestC) * 1000 );
(void)fastestD; (void)crcOrig; /* unused when decompression disabled */
#if 1
/* 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 {
+ UTIL_time_t const clockStart = UTIL_getTime();
+ U32 nbLoops;
+ for (nbLoops=0; nbLoops < nbDecodeLoops; nbLoops++) {
U32 blockNb;
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
size_t const regenSize = LZ4_decompress_safe(blockTable[blockNb].cPtr, blockTable[blockNb].resPtr, (int)blockTable[blockNb].cSize, (int)blockTable[blockNb].srcSize);
if (LZ4_isError(regenSize)) {
- DISPLAY("LZ4_decompress_safe() failed on block %u \n", blockNb);
- clockLoop = 0; /* force immediate test end */
+ DISPLAY("LZ4_decompress_safe() failed on block %u \n", blockNb);
break;
}
-
blockTable[blockNb].resSize = regenSize;
+ } }
+ { U64 const clockSpan = UTIL_clockSpanNano(clockStart);
+ if (clockSpan > 0) {
+ if (clockSpan < fastestD * nbDecodeLoops)
+ fastestD = clockSpan / nbDecodeLoops;
+ assert(fastestD > 0);
+ nbDecodeLoops = (U32)(TIMELOOP_NANOSEC / fastestD) + 1; /* aim for ~1sec */
+ } else {
+ assert(nbDecodeLoops < 40000000); /* avoid overflow */
+ nbDecodeLoops *= 100;
}
- nbLoops++;
- } while (UTIL_clockSpanMicro(clockStart) < DECOMP_MULT*clockLoop);
- { U64 const clockSpan = UTIL_clockSpanMicro(clockStart);
- if (clockSpan < fastestD*nbLoops) fastestD = clockSpan / nbLoops;
totalDTime += clockSpan;
- dCompleted = totalDTime>(DECOMP_MULT*maxTime);
+ dCompleted = totalDTime > (DECOMP_MULT*maxTime);
} }
markNb = (markNb+1) % NB_MARKS;
DISPLAYLEVEL(2, "%2s-%-17.17s :%10u ->%10u (%5.3f),%6.1f MB/s ,%6.1f MB/s\r",
marks[markNb], displayName, (U32)srcSize, (U32)cSize, ratio,
- (double)srcSize / fastestC,
- (double)srcSize / fastestD );
+ ((double)srcSize / fastestC) * 1000,
+ ((double)srcSize / fastestD) * 1000);
/* CRC Checking */
{ U64 const crcCheck = XXH64(resultBuffer, srcSize, 0);
@@ -339,8 +350,8 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
} /* for (testNb = 1; testNb <= (g_nbSeconds + !g_nbSeconds); testNb++) */
if (g_displayLevel == 1) {
- double cSpeed = (double)srcSize / fastestC;
- double dSpeed = (double)srcSize / fastestD;
+ double const cSpeed = ((double)srcSize / fastestC) * 1000;
+ double const dSpeed = ((double)srcSize / fastestD) * 1000;
if (g_additionalParam)
DISPLAY("-%-3i%11i (%5.3f) %6.2f MB/s %6.1f MB/s %s (param=%d)\n", cLevel, (int)cSize, ratio, cSpeed, dSpeed, displayName, g_additionalParam);
else
@@ -504,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<nbFiles; fileNb++)
+ BMK_benchFileTable(fileNamesTable+fileNb, 1, cLevel, cLevelLast);
+
+ return 0;
+}
+
+
int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
int cLevel, int cLevelLast)
{
@@ -516,7 +543,11 @@ int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
if (nbFiles == 0)
BMK_syntheticTest(cLevel, cLevelLast, compressibility);
- else
- BMK_benchFileTable(fileNamesTable, nbFiles, cLevel, cLevelLast);
+ else {
+ if (g_benchSeparately)
+ BMK_benchFilesSeparately(fileNamesTable, nbFiles, cLevel, cLevelLast);
+ else
+ BMK_benchFileTable(fileNamesTable, nbFiles, cLevel, cLevelLast);
+ }
return 0;
}
diff --git a/programs/bench.h b/programs/bench.h
index 15def93..bb67bee 100644
--- a/programs/bench.h
+++ b/programs/bench.h
@@ -29,9 +29,10 @@ int BMK_benchFiles(const char** fileNamesTable, unsigned nbFiles,
int cLevel, int cLevelLast);
/* Set Parameters */
-void BMK_SetNbSeconds(unsigned nbLoops);
-void BMK_SetBlockSize(size_t blockSize);
+void BMK_setNbSeconds(unsigned nbLoops);
+void BMK_setBlockSize(size_t blockSize);
void BMK_setAdditionalParam(int additionalParam);
void BMK_setNotificationLevel(unsigned level);
+void BMK_setBenchSeparately(int separate);
#endif /* BENCH_H_125623623633 */
diff --git a/programs/lz4.1.md b/programs/lz4.1.md
index b7b8570..a5168e9 100644
--- a/programs/lz4.1.md
+++ b/programs/lz4.1.md
@@ -117,9 +117,9 @@ only the latest one will be applied.
### Operation modifiers
* `-#`:
- Compression level, with # being any value from 1 to 16.
+ Compression level, with # being any value from 1 to 12.
Higher values trade compression speed for compression ratio.
- Values above 16 are considered the same as 16.
+ Values above 12 are considered the same as 12.
Recommended values are 1 for fast compression (default),
and 9 for high compression.
Speed/compression trade-off will vary depending on data to compress.
@@ -206,7 +206,7 @@ only the latest one will be applied.
Benchmark multiple compression levels, from b# to e# (included)
* `-i#`:
- Minimum evaluation in seconds \[1-9\] (default : 3)
+ Minimum evaluation time in seconds \[1-9\] (default : 3)
BUGS
diff --git a/programs/lz4cli.c b/programs/lz4cli.c
index 362ba49..ba519b4 100644
--- a/programs/lz4cli.c
+++ b/programs/lz4cli.c
@@ -140,6 +140,7 @@ static int usage_advanced(const char* exeName)
DISPLAY( "--no-frame-crc : disable stream checksum (default:enabled) \n");
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( "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");
@@ -355,6 +356,7 @@ int main(int argc, const char** argv)
if (!strcmp(argument, "--no-content-size")) { LZ4IO_setContentSize(0); continue; }
if (!strcmp(argument, "--sparse")) { LZ4IO_setSparseFile(2); continue; }
if (!strcmp(argument, "--no-sparse")) { LZ4IO_setSparseFile(0); continue; }
+ if (!strcmp(argument, "--favor-decSpeed")) { LZ4IO_favorDecSpeed(1); continue; }
if (!strcmp(argument, "--verbose")) { displayLevel++; continue; }
if (!strcmp(argument, "--quiet")) { if (displayLevel) displayLevel--; continue; }
if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; }
@@ -458,11 +460,11 @@ int main(int argc, const char** argv)
if (B < 4) badusage(exeName);
if (B <= 7) {
blockSize = LZ4IO_setBlockSizeID(B);
- BMK_SetBlockSize(blockSize);
+ BMK_setBlockSize(blockSize);
DISPLAYLEVEL(2, "using blocks of size %u KB \n", (U32)(blockSize>>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 +482,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 +502,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;
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 927928a..b52c1f3 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -56,8 +56,8 @@
#include "lz4io.h"
#include "lz4.h" /* still required for legacy format */
#include "lz4hc.h" /* still required for legacy format */
+#define LZ4F_STATIC_LINKING_ONLY
#include "lz4frame.h"
-#include "lz4frame_static.h"
/*****************************
@@ -94,9 +94,12 @@
static int g_displayLevel = 0; /* 0 : no display ; 1: errors ; 2 : + result + interaction + warnings ; 3 : + progression; 4 : + information */
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
- if (((clock_t)(g_time - clock()) > refreshRate) || (g_displayLevel>=4)) \
- { g_time = clock(); DISPLAY(__VA_ARGS__); \
- if (g_displayLevel>=4) fflush(stderr); } }
+ if ( ((clock() - g_time) > refreshRate) \
+ || (g_displayLevel>=4) ) { \
+ g_time = clock(); \
+ DISPLAY(__VA_ARGS__); \
+ if (g_displayLevel>=4) fflush(stderr); \
+ } }
static const clock_t refreshRate = CLOCKS_PER_SEC / 6;
static clock_t g_time = 0;
@@ -113,6 +116,7 @@ static int g_blockIndependence = 1;
static int g_sparseFileSupport = 1;
static int g_contentSizeFlag = 0;
static int g_useDictionary = 0;
+static unsigned g_favorDecSpeed = 0;
static const char* g_dictionaryFilename = NULL;
@@ -218,6 +222,12 @@ int LZ4IO_setContentSize(int enable)
return g_contentSizeFlag;
}
+/* Default setting : 0 (disabled) */
+void LZ4IO_favorDecSpeed(int favor)
+{
+ g_favorDecSpeed = (favor!=0);
+}
+
static U32 g_removeSrcFile = 0;
void LZ4IO_setRemoveSrcFile(unsigned flag) { g_removeSrcFile = (flag>0); }
@@ -545,6 +555,7 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
prefs.frameInfo.blockSizeID = (LZ4F_blockSizeID_t)g_blockSizeId;
prefs.frameInfo.blockChecksumFlag = (LZ4F_blockChecksum_t)g_blockChecksum;
prefs.frameInfo.contentChecksumFlag = (LZ4F_contentChecksum_t)g_streamChecksum;
+ prefs.favorDecSpeed = g_favorDecSpeed;
if (g_contentSizeFlag) {
U64 const fileSize = UTIL_getFileSize(srcFileName);
prefs.frameInfo.contentSize = fileSize; /* == 0 if input == stdin */
@@ -560,7 +571,7 @@ static int LZ4IO_compressFilename_extRess(cRess_t ress, const char* srcFileName,
/* single-block file */
if (readSize < blockSize) {
/* Compress in single pass */
- size_t cSize = LZ4F_compressFrame_usingCDict(dstBuffer, dstBufferSize, srcBuffer, readSize, ress.cdict, &prefs);
+ size_t cSize = LZ4F_compressFrame_usingCDict(ctx, dstBuffer, dstBufferSize, srcBuffer, readSize, ress.cdict, &prefs);
if (LZ4F_isError(cSize)) EXM_THROW(31, "Compression failed : %s", LZ4F_getErrorName(cSize));
compressedfilesize = cSize;
DISPLAYUPDATE(2, "\rRead : %u MB ==> %.2f%% ",
@@ -951,7 +962,7 @@ static unsigned long long LZ4IO_passThrough(FILE* finput, FILE* foutput, unsigne
total += readBytes;
storedSkips = LZ4IO_fwriteSparse(foutput, buffer, readBytes, storedSkips);
}
- if (ferror(finput)) EXM_THROW(51, "Read Error")
+ if (ferror(finput)) EXM_THROW(51, "Read Error");
LZ4IO_fwriteSparseEnd(foutput, storedSkips);
return total;
diff --git a/programs/lz4io.h b/programs/lz4io.h
index b21b8b6..22c5e3e 100644
--- a/programs/lz4io.h
+++ b/programs/lz4io.h
@@ -94,10 +94,15 @@ int LZ4IO_setNotificationLevel(int level);
/* Default setting : 0 (disabled) */
int LZ4IO_setSparseFile(int enable);
-/* Default setting : 0 (disabled) */
+/* Default setting : 0 == no content size present in frame header */
int LZ4IO_setContentSize(int enable);
+/* Default setting : 0 == src file preserved */
void LZ4IO_setRemoveSrcFile(unsigned flag);
+/* Default setting : 0 == favor compression ratio
+ * Note : 1 only works for high compression levels (10+) */
+void LZ4IO_favorDecSpeed(int favor);
+
#endif /* LZ4IO_H_237902873 */
diff --git a/programs/util.h b/programs/util.h
index fc7f63e..d74db0d 100644
--- a/programs/util.h
+++ b/programs/util.h
@@ -30,8 +30,9 @@ extern "C" {
* Dependencies
******************************************/
#include "platform.h" /* PLATFORM_POSIX_VERSION */
-#include <stdlib.h> /* malloc */
#include <stddef.h> /* size_t, ptrdiff_t */
+#include <stdlib.h> /* malloc */
+#include <string.h> /* strlen, strncpy */
#include <stdio.h> /* fprintf */
#include <sys/types.h> /* stat, utime */
#include <sys/stat.h> /* stat */
@@ -141,6 +142,7 @@ extern "C" {
* Time functions
******************************************/
#if defined(_WIN32) /* Windows */
+
typedef LARGE_INTEGER UTIL_time_t;
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { UTIL_time_t x; QueryPerformanceCounter(&x); return x; }
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
@@ -165,7 +167,9 @@ extern "C" {
}
return 1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart;
}
+
#elif defined(__APPLE__) && defined(__MACH__)
+
#include <mach/mach_time.h>
typedef U64 UTIL_time_t;
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { return mach_absolute_time(); }
@@ -177,7 +181,7 @@ extern "C" {
mach_timebase_info(&rate);
init = 1;
}
- return (((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom))/1000ULL;
+ return (((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom)) / 1000ULL;
}
UTIL_STATIC U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
{
@@ -189,7 +193,9 @@ extern "C" {
}
return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom);
}
-#elif (PLATFORM_POSIX_VERSION >= 200112L)
+
+#elif (PLATFORM_POSIX_VERSION >= 200112L) && (defined __UCLIBC__ || (defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) ) )
+
#include <time.h>
typedef struct timespec UTIL_time_t;
UTIL_STATIC UTIL_time_t UTIL_getTime(void)
@@ -227,7 +233,9 @@ extern "C" {
nano += diff.tv_nsec;
return nano;
}
+
#else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threading) */
+
typedef clock_t UTIL_time_t;
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { return clock(); }
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
@@ -242,6 +250,12 @@ UTIL_STATIC U64 UTIL_clockSpanMicro(UTIL_time_t clockStart)
return UTIL_getSpanTimeMicro(clockStart, clockEnd);
}
+/* returns time span in nanoseconds */
+UTIL_STATIC U64 UTIL_clockSpanNano(UTIL_time_t clockStart)
+{
+ UTIL_time_t const clockEnd = UTIL_getTime();
+ return UTIL_getSpanTimeNano(clockStart, clockEnd);
+}
UTIL_STATIC void UTIL_waitForNextTick(void)
{