if (depth==0) goto _storeSequence;
} else {
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
- int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/);
- int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1);
+ int gain2 = (int)(mlRep * 3 /*- ZSTD_highbit((U32)i+1)*/ + (i==1));
+ int gain1 = (int)(matchLength*3 - /*ZSTD_highbit((U32)offset+1)*/ + 1 + (offset==1));
if (gain2 > gain1)
matchLength = mlRep, offset = i;
}
while (ip<ilimit) {
ip ++;
for (int i=0; i<ZSTD_REP_NUM; i++)
- if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
+ if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
size_t mlRep = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(mlRep * 3);
- int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1);
+ int gain1 = (int)(matchLength*3 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
if ((mlRep >= MINMATCH) && (gain2 > gain1))
matchLength = mlRep, offset = i, start = ip;
}
if ((depth==2) && (ip<ilimit)) {
ip ++;
for (int i=0; i<ZSTD_REP_NUM; i++)
- if ((offset >= ZSTD_REP_NUM) && (MEM_read32(ip) == MEM_read32(ip - rep[i]))) {
+ if (MEM_read32(ip) == MEM_read32(ip - rep[i])) {
size_t ml2 = ZSTD_count(ip+MINMATCH, ip+MINMATCH-rep[i], iend) + MINMATCH;
int gain2 = (int)(ml2 * 4);
- int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1);
+ int gain1 = (int)(matchLength*4 - ZSTD_highbit((U32)offset+1) + 1 + (offset<ZSTD_REP_NUM));
if ((ml2 >= MINMATCH) && (gain2 > gain1))
matchLength = ml2, offset = i, start = ip;
}
{
#if ZSTD_REP_NUM == 4
if (offset >= ZSTD_REP_NUM) {
-#if 0
+#if 1
rep[3] = rep[2];
rep[2] = rep[1];
rep[1] = rep[0];
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
seqState->prevOffset[2] = seqState->prevOffset[1];
}
- offset = temp;
seqState->prevOffset[1] = seqState->prevOffset[0];
- seqState->prevOffset[0] = offset;
+ seqState->prevOffset[0] = offset = temp;
+
} else {
offset = seqState->prevOffset[0];
}
} else {
offset -= ZSTD_REP_MOVE;
+#if 1 // faster without kSlotNew
+ seqState->prevOffset[3] = seqState->prevOffset[2];
+ seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset;
+#else
if (kSlotNew < 3) seqState->prevOffset[3] = seqState->prevOffset[2];
if (kSlotNew < 2) seqState->prevOffset[2] = seqState->prevOffset[1];
if (kSlotNew < 1) seqState->prevOffset[1] = seqState->prevOffset[0];
seqState->prevOffset[kSlotNew] = offset;
+#endif
}
#else // ZSTD_REP_NUM == 1
#if 0
#else
#define ZSTD_REP_NUM 1
#define ZSTD_REP_INIT 2
- #define ZSTD_REP_MOVE 0//(ZSTD_REP_NUM-1)
+ #define ZSTD_REP_MOVE 0 //(ZSTD_REP_NUM-1)
#endif
#define KB *(1 <<10)
PREFIX ?= /usr/local
CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\"
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
-CFLAGS += -std=c99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
+CFLAGS += -std=gnu99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
BINDIR = $(PREFIX)/bin
#include <stdio.h> /* fprintf, fopen, ftello64 */
#include <sys/types.h> /* stat64 */
#include <sys/stat.h> /* stat64 */
-#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
+#include <time.h> /* clock_t, clock, nanosleep, CLOCKS_PER_SEC */
#ifdef WINDOWS
- #define mili_sleep(mili) Sleep(mili)
+ #define mili_sleep(mili) Sleep(mili)
#else
- #define mili_sleep(mili) usleep(mili*1000)
#include <sys/resource.h> /* setpriority */
+ #define mili_sleep(mili) { struct timespec t; t.tv_sec=0; t.tv_nsec=mili*1000000L; nanosleep(&t, NULL); }
#endif
-
+
/* sleep : posix - windows - others */
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
# include <unistd.h>
if (crcOrig == crcCheck)
{
- DISPLAYLEVEL(2, "%2i-%-17.17s :%10i ->%10i (%5.3f),%6.1f MB/s ,%6.1f MB/s \n", cLevel, displayName, (int)srcSize, (int)cSize, ratio, (double)srcSize / fastestC / 1000., (double)srcSize / fastestD / 1000.);
result->ratio = ratio;
result->cSize = cSize;
- result->cSpeed = (double)srcSize / fastestC / 1000.;
- result->dSpeed = (double)srcSize / fastestD / 1000.;
+ result->cSpeed = (double)srcSize / 1000000. / (fastestC / CLOCKS_PER_SEC);
+ result->dSpeed = (double)srcSize / 1000000. / (fastestD / CLOCKS_PER_SEC);
+ DISPLAYLEVEL(2, "%2i-%-17.17s :%10i ->%10i (%5.3f),%6.1f MB/s ,%6.1f MB/s \n", cLevel, displayName, (int)srcSize, (int)cSize, ratio, result->cSpeed, result->dSpeed);
}
else
DISPLAYLEVEL(2, "%2i-\n", cLevel);
dictBuffer, dictBufferSize, &result);
if (g_displayLevel == 1) {
if (additionalParam)
- DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (p=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam);
+ DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s (param=%d)\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName, additionalParam);
else
DISPLAY("%-3i%11i (%5.3f) %6.1f MB/s %6.1f MB/s %s\n", -l, (int)result.cSize, result.ratio, result.cSpeed, result.dSpeed, displayName);
total.cSize += result.cSize;