removed clock_gettime (not portable)
This commit is contained in:
parent
4611d11fea
commit
33ad251236
@ -48,7 +48,6 @@ 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
|
||||
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
|
||||
LDFLAGS ?= -lrt
|
||||
|
||||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
@ -87,11 +86,11 @@ all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 zbufftest zbufftest32 par
|
||||
|
||||
zstd : $(ZSTD_FILES) $(ZSTD_FILES_LEGACY) $(ZSTDDIR)/zbuff.c $(ZSTDDIR)/zdict.c $(ZSTDDIR)/divsufsort.c \
|
||||
zstdcli.c fileio.c bench.c xxhash.c datagen.c dibio.c
|
||||
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ $(LDFLAGS) -o $@$(EXT)
|
||||
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
|
||||
|
||||
zstd32: $(ZSTD_FILES) $(ZSTD_FILES_LEGACY) $(ZSTDDIR)/zbuff.c $(ZSTDDIR)/zdict.c $(ZSTDDIR)/divsufsort.c \
|
||||
zstdcli.c fileio.c bench.c xxhash.c datagen.c dibio.c
|
||||
$(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ $(LDFLAGS) -o $@$(EXT)
|
||||
$(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
|
||||
|
||||
zstd_nolegacy :
|
||||
$(MAKE) zstd ZSTD_LEGACY_SUPPORT=0
|
||||
|
@ -70,43 +70,20 @@
|
||||
# define setHighPriority() /* disabled */
|
||||
#endif
|
||||
|
||||
/*
|
||||
Windows QueryPerformanceCounter resolution = 410 nanosec
|
||||
Windows clock() resolution = 1000000 nanosec
|
||||
VirtualBox Ubuntu clock() resolution = 1000 nanosec
|
||||
VirtualBox Ubuntu clock_gettime() resolution = 100-280 nanosec
|
||||
fizzle clock() resolution = 1000 nanosec
|
||||
fizzle clock_gettime() resolution = 100-280 nanosec
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
|
||||
|
||||
#if 0
|
||||
typedef clock_t BMK_time_t;
|
||||
# define BMK_TIME_FUNCTION "clock()"
|
||||
# define BMK_initTimer(ticksPerSecond) (void)ticksPerSecond
|
||||
# define BMK_getTime(x) x = clock()
|
||||
# define BMK_getSpanTimeMicro(ticksPerSecond, clockStart, clockEnd) (1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC)
|
||||
# define BMK_getSpanTimeNano(ticksPerSecond, clockStart, clockEnd) (1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC)
|
||||
#else
|
||||
typedef struct timespec BMK_time_t;
|
||||
# define BMK_TIME_FUNCTION "clock_gettime"
|
||||
# define BMK_initTimer(ticksPerSecond) (void)ticksPerSecond
|
||||
# define BMK_getTime(x) if (clock_gettime(CLOCK_MONOTONIC, &x) == -1 ){ fprintf(stderr, "ERROR: clock_gettime error\n"); }
|
||||
# define BMK_getSpanTimeMicro(ticksPerSecond, clockStart, clockEnd) (1000000ULL*( clockEnd.tv_sec - clockStart.tv_sec ) + ( clockEnd.tv_nsec - clockStart.tv_nsec ) / 1000)
|
||||
# define BMK_getSpanTimeNano(ticksPerSecond, clockStart, clockEnd) (1000000000ULL*( clockEnd.tv_sec - clockStart.tv_sec ) + ( clockEnd.tv_nsec - clockStart.tv_nsec ))
|
||||
#endif
|
||||
|
||||
#elif defined(_WIN32)
|
||||
typedef LARGE_INTEGER BMK_time_t;
|
||||
# define BMK_TIME_FUNCTION "QueryPerformanceFrequency"
|
||||
# define BMK_initTimer(x) if (!QueryPerformanceFrequency(&x)) { fprintf(stderr, "ERROR: QueryPerformance not present\n"); }
|
||||
# define BMK_getTime(x) QueryPerformanceCounter(&x)
|
||||
# define BMK_getSpanTimeMicro(ticksPerSecond, clockStart, clockEnd) (1000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart)
|
||||
# define BMK_getSpanTimeNano(ticksPerSecond, clockStart, clockEnd) (1000000000ULL*(clockEnd.QuadPart - clockStart.QuadPart)/ticksPerSecond.QuadPart)
|
||||
#else
|
||||
typedef int BMK_time_t;
|
||||
# define BMK_TIME_FUNCTION "None"
|
||||
# define BMK_initTimer(ticksPerSecond) (void)ticksPerSecond
|
||||
# define BMK_getTimeMicro(clockStart) clockStart=1
|
||||
# define BMK_getSpanTimeMicro(ticksPerSecond, clockStart, clockEnd) (TIMELOOP_S*1000000ULL+clockEnd-clockStart)
|
||||
@ -284,17 +261,6 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
||||
if (strlen(displayName)>17) displayName += strlen(displayName)-17; /* can only display 17 characters */
|
||||
BMK_initTimer(ticksPerSecond);
|
||||
|
||||
{
|
||||
BMK_time_t clockStart, clockEnd;
|
||||
|
||||
BMK_getTime(clockStart);
|
||||
do { BMK_getTime(clockEnd); }
|
||||
while (BMK_getSpanTimeNano(ticksPerSecond, clockStart, clockEnd) == 0);
|
||||
|
||||
printf(BMK_TIME_FUNCTION " resolution = %d nanosec\n", (int)BMK_getSpanTimeNano(ticksPerSecond, clockStart, clockEnd));
|
||||
}
|
||||
|
||||
|
||||
/* Init blockTable data */
|
||||
{ const char* srcPtr = (const char*)srcBuffer;
|
||||
char* cPtr = (char*)compressedBuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user