mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Use util.h for timing
This commit is contained in:
@ -34,7 +34,6 @@
|
|||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#include <stdio.h> /* fprintf, fopen */
|
#include <stdio.h> /* fprintf, fopen */
|
||||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
|
||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#define ZSTD_STATIC_LINKING_ONLY
|
#define ZSTD_STATIC_LINKING_ONLY
|
||||||
@ -72,12 +71,14 @@ static U32 g_compressibilityDefault = 50;
|
|||||||
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
||||||
static int g_displayLevel = 2; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
|
static int g_displayLevel = 2; /* 0 : no display; 1: errors; 2 : + result + interaction + warnings; 3 : + progression; 4 : + information */
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
#define SEC_TO_MICRO 1000000
|
||||||
if ((clock() - g_time > refreshRate) || (g_displayLevel>=4)) \
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
{ g_time = clock(); DISPLAY(__VA_ARGS__); \
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
if (g_displayLevel>=4) fflush(stderr); } }
|
|
||||||
static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
|
#define DISPLAYUPDATE(l, ...) { if (g_displayLevel>=l) { \
|
||||||
static clock_t g_time = 0;
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
||||||
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
|
if (g_displayLevel>=4) fflush(stderr); } } }
|
||||||
|
|
||||||
|
|
||||||
/* *************************************
|
/* *************************************
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* memset */
|
#include <string.h> /* memset */
|
||||||
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
||||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
|
|
||||||
#include "mem.h" /* read */
|
#include "mem.h" /* read */
|
||||||
@ -55,15 +54,14 @@ static const size_t g_maxMemory = (sizeof(size_t) == 4) ? (2 GB - 64 MB) : ((siz
|
|||||||
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
|
||||||
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) if (displayLevel>=l) { \
|
#define SEC_TO_MICRO 1000000
|
||||||
if ((DIB_clockSpan(g_time) > refreshRate) || (displayLevel>=4)) \
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
{ g_time = clock(); DISPLAY(__VA_ARGS__); \
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
if (displayLevel>=4) fflush(stderr); } }
|
|
||||||
static const clock_t refreshRate = CLOCKS_PER_SEC * 2 / 10;
|
|
||||||
static clock_t g_time = 0;
|
|
||||||
|
|
||||||
static clock_t DIB_clockSpan(clock_t nPrevious) { return clock() - nPrevious; }
|
|
||||||
|
|
||||||
|
#define DISPLAYUPDATE(l, ...) { if (displayLevel>=l) { \
|
||||||
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (displayLevel>=4)) \
|
||||||
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
|
if (displayLevel>=4) fflush(stderr); } } }
|
||||||
|
|
||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Exceptions
|
* Exceptions
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <stdio.h> /* fprintf, fopen, fread, _fileno, stdin, stdout */
|
#include <stdio.h> /* fprintf, fopen, fread, _fileno, stdin, stdout */
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <string.h> /* strcmp, strlen */
|
#include <string.h> /* strcmp, strlen */
|
||||||
#include <time.h> /* clock */
|
|
||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
|
|
||||||
#if defined (_MSC_VER)
|
#if defined (_MSC_VER)
|
||||||
@ -40,6 +39,7 @@
|
|||||||
#include "bitstream.h"
|
#include "bitstream.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
|
#include "util.h"
|
||||||
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_magicNumber, ZSTD_frameHeaderSize_max */
|
||||||
#include "zstd.h"
|
#include "zstd.h"
|
||||||
#if defined(ZSTD_GZCOMPRESS) || defined(ZSTD_GZDECOMPRESS)
|
#if defined(ZSTD_GZCOMPRESS) || defined(ZSTD_GZDECOMPRESS)
|
||||||
@ -81,12 +81,14 @@
|
|||||||
static int g_displayLevel = 2; /* 0 : no display; 1: errors; 2: + result + interaction + warnings; 3: + progression; 4: + information */
|
static int g_displayLevel = 2; /* 0 : no display; 1: errors; 2: + result + interaction + warnings; 3: + progression; 4: + information */
|
||||||
void FIO_setNotificationLevel(unsigned level) { g_displayLevel=level; }
|
void FIO_setNotificationLevel(unsigned level) { g_displayLevel=level; }
|
||||||
|
|
||||||
|
#define SEC_TO_MICRO 1000000
|
||||||
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) { if (g_displayLevel>=l) { \
|
#define DISPLAYUPDATE(l, ...) { if (g_displayLevel>=l) { \
|
||||||
if ((clock() - g_time > refreshRate) || (g_displayLevel>=4)) \
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
||||||
{ g_time = clock(); DISPLAY(__VA_ARGS__); \
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
if (g_displayLevel>=4) fflush(stderr); } } }
|
if (g_displayLevel>=4) fflush(stderr); } } }
|
||||||
static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
|
|
||||||
static clock_t g_time = 0;
|
|
||||||
|
|
||||||
#undef MIN /* in case it would be already defined */
|
#undef MIN /* in case it would be already defined */
|
||||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
@ -118,6 +118,7 @@ static int g_utilDisplayLevel;
|
|||||||
* Time functions
|
* Time functions
|
||||||
******************************************/
|
******************************************/
|
||||||
#if defined(_WIN32) /* Windows */
|
#if defined(_WIN32) /* Windows */
|
||||||
|
#define UTIL_TIME_INITIALIZER { { 0, 0 } }
|
||||||
typedef LARGE_INTEGER UTIL_time_t;
|
typedef LARGE_INTEGER UTIL_time_t;
|
||||||
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { UTIL_time_t x; QueryPerformanceCounter(&x); return x; }
|
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)
|
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||||
@ -144,6 +145,7 @@ static int g_utilDisplayLevel;
|
|||||||
}
|
}
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
#elif defined(__APPLE__) && defined(__MACH__)
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
|
#define UTIL_TIME_INITIALIZER 0
|
||||||
typedef U64 UTIL_time_t;
|
typedef U64 UTIL_time_t;
|
||||||
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { return mach_absolute_time(); }
|
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { return mach_absolute_time(); }
|
||||||
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd)
|
||||||
@ -168,6 +170,7 @@ static int g_utilDisplayLevel;
|
|||||||
}
|
}
|
||||||
#elif (PLATFORM_POSIX_VERSION >= 200112L)
|
#elif (PLATFORM_POSIX_VERSION >= 200112L)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#define UTIL_TIME_INITIALIZER { 0, 0 }
|
||||||
typedef struct timespec UTIL_freq_t;
|
typedef struct timespec UTIL_freq_t;
|
||||||
typedef struct timespec UTIL_time_t;
|
typedef struct timespec UTIL_time_t;
|
||||||
UTIL_STATIC UTIL_time_t UTIL_getTime(void)
|
UTIL_STATIC UTIL_time_t UTIL_getTime(void)
|
||||||
@ -207,6 +210,7 @@ static int g_utilDisplayLevel;
|
|||||||
}
|
}
|
||||||
#else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threading) */
|
#else /* relies on standard C (note : clock_t measurements can be wrong when using multi-threading) */
|
||||||
typedef clock_t UTIL_time_t;
|
typedef clock_t UTIL_time_t;
|
||||||
|
#define UTIL_TIME_INITIALIZER 0
|
||||||
UTIL_STATIC UTIL_time_t UTIL_getTime(void) { return clock(); }
|
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; }
|
UTIL_STATIC U64 UTIL_getSpanTimeMicro(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
|
||||||
UTIL_STATIC U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
|
UTIL_STATIC U64 UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd) { return 1000000000ULL * (clockEnd - clockStart) / CLOCKS_PER_SEC; }
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
#include "zstd.h"
|
#include "zstd.h"
|
||||||
#include "zstd_internal.h"
|
#include "zstd_internal.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
@ -49,20 +49,17 @@ static U32 g_displayLevel = 2;
|
|||||||
|
|
||||||
#define DISPLAYUPDATE(...) \
|
#define DISPLAYUPDATE(...) \
|
||||||
do { \
|
do { \
|
||||||
if ((clockSpan(g_displayClock) > g_refreshRate) || \
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || \
|
||||||
(g_displayLevel >= 4)) { \
|
(g_displayLevel >= 4)) { \
|
||||||
g_displayClock = clock(); \
|
g_displayClock = UTIL_getTime(); \
|
||||||
DISPLAY(__VA_ARGS__); \
|
DISPLAY(__VA_ARGS__); \
|
||||||
if (g_displayLevel >= 4) fflush(stderr); \
|
if (g_displayLevel >= 4) fflush(stderr); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
static const clock_t g_refreshRate = CLOCKS_PER_SEC / 6;
|
|
||||||
static clock_t g_displayClock = 0;
|
|
||||||
|
|
||||||
static clock_t clockSpan(clock_t cStart)
|
#define SEC_TO_MICRO 1000000
|
||||||
{
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
return clock() - cStart; /* works even when overflow; max span ~ 30mn */
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
}
|
|
||||||
|
|
||||||
#define CHECKERR(code) \
|
#define CHECKERR(code) \
|
||||||
do { \
|
do { \
|
||||||
@ -1531,14 +1528,14 @@ static int runTestMode(U32 seed, unsigned numFiles, unsigned const testDurationS
|
|||||||
{
|
{
|
||||||
unsigned fnum;
|
unsigned fnum;
|
||||||
|
|
||||||
clock_t const startClock = clock();
|
UTIL_time_t const startClock = UTIL_getTime();
|
||||||
clock_t const maxClockSpan = testDurationS * CLOCKS_PER_SEC;
|
U64 const maxClockSpan = testDurationS * SEC_TO_MICRO;
|
||||||
|
|
||||||
if (numFiles == 0 && !testDurationS) numFiles = 1;
|
if (numFiles == 0 && !testDurationS) numFiles = 1;
|
||||||
|
|
||||||
DISPLAY("seed: %u\n", seed);
|
DISPLAY("seed: %u\n", seed);
|
||||||
|
|
||||||
for (fnum = 0; fnum < numFiles || clockSpan(startClock) < maxClockSpan; fnum++) {
|
for (fnum = 0; fnum < numFiles || UTIL_clockSpanMicro(startClock) < maxClockSpan; fnum++) {
|
||||||
if (fnum < numFiles)
|
if (fnum < numFiles)
|
||||||
DISPLAYUPDATE("\r%u/%u ", fnum, numFiles);
|
DISPLAYUPDATE("\r%u/%u ", fnum, numFiles);
|
||||||
else
|
else
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdlib.h> /* free */
|
#include <stdlib.h> /* free */
|
||||||
#include <stdio.h> /* fgets, sscanf */
|
#include <stdio.h> /* fgets, sscanf */
|
||||||
#include <string.h> /* strcmp */
|
#include <string.h> /* strcmp */
|
||||||
#include <time.h> /* clock_t */
|
|
||||||
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressContinue, ZSTD_compressBlock */
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressContinue, ZSTD_compressBlock */
|
||||||
#include "zstd.h" /* ZSTD_VERSION_STRING */
|
#include "zstd.h" /* ZSTD_VERSION_STRING */
|
||||||
#include "zstd_errors.h" /* ZSTD_getErrorCode */
|
#include "zstd_errors.h" /* ZSTD_getErrorCode */
|
||||||
@ -36,6 +35,7 @@
|
|||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#define XXH_STATIC_LINKING_ONLY
|
#define XXH_STATIC_LINKING_ONLY
|
||||||
#include "xxhash.h" /* XXH64 */
|
#include "xxhash.h" /* XXH64 */
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
@ -56,25 +56,23 @@ static const U32 nbTestsDefault = 30000;
|
|||||||
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
||||||
static U32 g_displayLevel = 2;
|
static U32 g_displayLevel = 2;
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
#define SEC_TO_MICRO 1000000
|
||||||
if ((FUZ_clockSpan(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
{ g_displayClock = clock(); DISPLAY(__VA_ARGS__); \
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
if (g_displayLevel>=4) fflush(stdout); } }
|
|
||||||
static const clock_t g_refreshRate = CLOCKS_PER_SEC / 6;
|
|
||||||
static clock_t g_displayClock = 0;
|
|
||||||
|
|
||||||
|
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
||||||
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
||||||
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
|
if (g_displayLevel>=4) fflush(stderr); } }
|
||||||
|
|
||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Fuzzer functions
|
* Fuzzer functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
static clock_t FUZ_clockSpan(clock_t cStart)
|
|
||||||
{
|
|
||||||
return clock() - cStart; /* works even when overflow; max span ~ 30mn */
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
|
#define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
|
||||||
static unsigned FUZ_rand(unsigned* src)
|
static unsigned FUZ_rand(unsigned* src)
|
||||||
{
|
{
|
||||||
@ -1208,8 +1206,8 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, U32 const maxD
|
|||||||
U32 result = 0;
|
U32 result = 0;
|
||||||
U32 testNb = 0;
|
U32 testNb = 0;
|
||||||
U32 coreSeed = seed, lseed = 0;
|
U32 coreSeed = seed, lseed = 0;
|
||||||
clock_t const startClock = clock();
|
UTIL_time_t const startClock = UTIL_getTime();
|
||||||
clock_t const maxClockSpan = maxDurationS * CLOCKS_PER_SEC;
|
U64 const maxClockSpan = maxDurationS * SEC_TO_MICRO;
|
||||||
int const cLevelLimiter = bigTests ? 3 : 2;
|
int const cLevelLimiter = bigTests ? 3 : 2;
|
||||||
|
|
||||||
/* allocation */
|
/* allocation */
|
||||||
@ -1234,7 +1232,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, U32 const maxD
|
|||||||
for (testNb=1; testNb < startTest; testNb++) FUZ_rand(&coreSeed);
|
for (testNb=1; testNb < startTest; testNb++) FUZ_rand(&coreSeed);
|
||||||
|
|
||||||
/* main test loop */
|
/* main test loop */
|
||||||
for ( ; (testNb <= nbTests) || (FUZ_clockSpan(startClock) < maxClockSpan); testNb++ ) {
|
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < maxClockSpan); testNb++ ) {
|
||||||
size_t sampleSize, maxTestSize, totalTestSize;
|
size_t sampleSize, maxTestSize, totalTestSize;
|
||||||
size_t cSize, totalCSize, totalGenSize;
|
size_t cSize, totalCSize, totalGenSize;
|
||||||
U64 crcOrig;
|
U64 crcOrig;
|
||||||
|
@ -17,13 +17,14 @@
|
|||||||
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
#include <stdio.h> /* fprintf, fopen, ftello64 */
|
||||||
#include <string.h> /* strcmp */
|
#include <string.h> /* strcmp */
|
||||||
#include <math.h> /* log */
|
#include <math.h> /* log */
|
||||||
#include <time.h> /* clock_t */
|
#include <time.h>
|
||||||
|
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_estimateCCtxSize */
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_estimateCCtxSize */
|
||||||
#include "zstd.h"
|
#include "zstd.h"
|
||||||
#include "datagen.h"
|
#include "datagen.h"
|
||||||
#include "xxhash.h"
|
#include "xxhash.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
@ -38,8 +39,9 @@
|
|||||||
#define MB *(1<<20)
|
#define MB *(1<<20)
|
||||||
#define GB *(1ULL<<30)
|
#define GB *(1ULL<<30)
|
||||||
|
|
||||||
|
#define SEC_TO_MICRO 1000000
|
||||||
#define NBLOOPS 2
|
#define NBLOOPS 2
|
||||||
#define TIMELOOP (2 * CLOCKS_PER_SEC)
|
#define TIMELOOP (2 * SEC_TO_MICRO)
|
||||||
|
|
||||||
#define NB_LEVELS_TRACKED 30
|
#define NB_LEVELS_TRACKED 30
|
||||||
|
|
||||||
@ -49,8 +51,8 @@ static const size_t maxMemory = (sizeof(size_t)==4) ? (2 GB - 64 MB) : (size_t
|
|||||||
static const size_t sampleSize = 10000000;
|
static const size_t sampleSize = 10000000;
|
||||||
|
|
||||||
static const double g_grillDuration_s = 90000; /* about 24 hours */
|
static const double g_grillDuration_s = 90000; /* about 24 hours */
|
||||||
static const clock_t g_maxParamTime = 15 * CLOCKS_PER_SEC;
|
static const U64 g_maxParamTime = 15 * SEC_TO_MICRO;
|
||||||
static const clock_t g_maxVariationTime = 60 * CLOCKS_PER_SEC;
|
static const U64 g_maxVariationTime = 60 * SEC_TO_MICRO;
|
||||||
static const int g_maxNbVariations = 64;
|
static const int g_maxNbVariations = 64;
|
||||||
|
|
||||||
|
|
||||||
@ -88,13 +90,9 @@ void BMK_SetNbIterations(int nbLoops)
|
|||||||
* Private functions
|
* Private functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
|
||||||
/* works even if overflow ; max span ~ 30 mn */
|
|
||||||
static clock_t BMK_clockSpan(clock_t cStart) { return clock() - cStart; }
|
|
||||||
|
|
||||||
/* accuracy in seconds only, span can be multiple years */
|
/* accuracy in seconds only, span can be multiple years */
|
||||||
static double BMK_timeSpan(time_t tStart) { return difftime(time(NULL), tStart); }
|
static double BMK_timeSpan(time_t tStart) { return difftime(time(NULL), tStart); }
|
||||||
|
|
||||||
|
|
||||||
static size_t BMK_findMaxMem(U64 requiredMem)
|
static size_t BMK_findMaxMem(U64 requiredMem)
|
||||||
{
|
{
|
||||||
size_t const step = 64 MB;
|
size_t const step = 64 MB;
|
||||||
@ -221,7 +219,7 @@ static size_t BMK_benchParam(BMK_result_t* resultPtr,
|
|||||||
size_t cSize = 0;
|
size_t cSize = 0;
|
||||||
double fastestC = 100000000., fastestD = 100000000.;
|
double fastestC = 100000000., fastestD = 100000000.;
|
||||||
double ratio = 0.;
|
double ratio = 0.;
|
||||||
clock_t const benchStart = clock();
|
UTIL_time_t const benchStart = UTIL_getTime();
|
||||||
|
|
||||||
DISPLAY("\r%79s\r", "");
|
DISPLAY("\r%79s\r", "");
|
||||||
memset(¶ms, 0, sizeof(params));
|
memset(¶ms, 0, sizeof(params));
|
||||||
@ -229,9 +227,10 @@ static size_t BMK_benchParam(BMK_result_t* resultPtr,
|
|||||||
for (loopNb = 1; loopNb <= g_nbIterations; loopNb++) {
|
for (loopNb = 1; loopNb <= g_nbIterations; loopNb++) {
|
||||||
int nbLoops;
|
int nbLoops;
|
||||||
U32 blockNb;
|
U32 blockNb;
|
||||||
clock_t roundStart, roundClock;
|
UTIL_time_t roundStart;
|
||||||
|
U64 roundClock;
|
||||||
|
|
||||||
{ clock_t const benchTime = BMK_clockSpan(benchStart);
|
{ U64 const benchTime = UTIL_clockSpanMicro(benchStart);
|
||||||
if (benchTime > g_maxParamTime) break; }
|
if (benchTime > g_maxParamTime) break; }
|
||||||
|
|
||||||
/* Compression */
|
/* Compression */
|
||||||
@ -239,10 +238,9 @@ static size_t BMK_benchParam(BMK_result_t* resultPtr,
|
|||||||
memset(compressedBuffer, 0xE5, maxCompressedSize);
|
memset(compressedBuffer, 0xE5, maxCompressedSize);
|
||||||
|
|
||||||
nbLoops = 0;
|
nbLoops = 0;
|
||||||
roundStart = clock();
|
UTIL_waitForNextTick();
|
||||||
while (clock() == roundStart);
|
roundStart = UTIL_getTime();
|
||||||
roundStart = clock();
|
while (UTIL_clockSpanMicro(roundStart) < TIMELOOP) {
|
||||||
while (BMK_clockSpan(roundStart) < TIMELOOP) {
|
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
||||||
blockTable[blockNb].cSize = ZSTD_compress_advanced(ctx,
|
blockTable[blockNb].cSize = ZSTD_compress_advanced(ctx,
|
||||||
blockTable[blockNb].cPtr, blockTable[blockNb].cRoom,
|
blockTable[blockNb].cPtr, blockTable[blockNb].cRoom,
|
||||||
@ -251,13 +249,13 @@ static size_t BMK_benchParam(BMK_result_t* resultPtr,
|
|||||||
params);
|
params);
|
||||||
nbLoops++;
|
nbLoops++;
|
||||||
}
|
}
|
||||||
roundClock = BMK_clockSpan(roundStart);
|
roundClock = UTIL_clockSpanMicro(roundStart);
|
||||||
|
|
||||||
cSize = 0;
|
cSize = 0;
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
||||||
cSize += blockTable[blockNb].cSize;
|
cSize += blockTable[blockNb].cSize;
|
||||||
ratio = (double)srcSize / (double)cSize;
|
ratio = (double)srcSize / (double)cSize;
|
||||||
if ((double)roundClock < fastestC * CLOCKS_PER_SEC * nbLoops) fastestC = ((double)roundClock / CLOCKS_PER_SEC) / nbLoops;
|
if ((double)roundClock < fastestC * SEC_TO_MICRO * nbLoops) fastestC = ((double)roundClock / SEC_TO_MICRO) / nbLoops;
|
||||||
DISPLAY("\r");
|
DISPLAY("\r");
|
||||||
DISPLAY("%1u-%s : %9u ->", loopNb, name, (U32)srcSize);
|
DISPLAY("%1u-%s : %9u ->", loopNb, name, (U32)srcSize);
|
||||||
DISPLAY(" %9u (%4.3f),%7.1f MB/s", (U32)cSize, ratio, (double)srcSize / fastestC / 1000000.);
|
DISPLAY(" %9u (%4.3f),%7.1f MB/s", (U32)cSize, ratio, (double)srcSize / fastestC / 1000000.);
|
||||||
@ -269,17 +267,16 @@ static size_t BMK_benchParam(BMK_result_t* resultPtr,
|
|||||||
memset(resultBuffer, 0xD6, srcSize);
|
memset(resultBuffer, 0xD6, srcSize);
|
||||||
|
|
||||||
nbLoops = 0;
|
nbLoops = 0;
|
||||||
roundStart = clock();
|
UTIL_waitForNextTick();
|
||||||
while (clock() == roundStart);
|
roundStart = UTIL_getTime();
|
||||||
roundStart = clock();
|
for ( ; UTIL_clockSpanMicro(roundStart) < TIMELOOP; nbLoops++) {
|
||||||
for ( ; BMK_clockSpan(roundStart) < TIMELOOP; nbLoops++) {
|
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
for (blockNb=0; blockNb<nbBlocks; blockNb++)
|
||||||
blockTable[blockNb].resSize = ZSTD_decompress(blockTable[blockNb].resPtr, blockTable[blockNb].srcSize,
|
blockTable[blockNb].resSize = ZSTD_decompress(blockTable[blockNb].resPtr, blockTable[blockNb].srcSize,
|
||||||
blockTable[blockNb].cPtr, blockTable[blockNb].cSize);
|
blockTable[blockNb].cPtr, blockTable[blockNb].cSize);
|
||||||
}
|
}
|
||||||
roundClock = BMK_clockSpan(roundStart);
|
roundClock = UTIL_clockSpanMicro(roundStart);
|
||||||
|
|
||||||
if ((double)roundClock < fastestD * CLOCKS_PER_SEC * nbLoops) fastestD = ((double)roundClock / CLOCKS_PER_SEC) / nbLoops;
|
if ((double)roundClock < fastestD * SEC_TO_MICRO * nbLoops) fastestD = ((double)roundClock / SEC_TO_MICRO) / nbLoops;
|
||||||
DISPLAY("\r");
|
DISPLAY("\r");
|
||||||
DISPLAY("%1u-%s : %9u -> ", loopNb, name, (U32)srcSize);
|
DISPLAY("%1u-%s : %9u -> ", loopNb, name, (U32)srcSize);
|
||||||
DISPLAY("%9u (%4.3f),%7.1f MB/s, ", (U32)cSize, ratio, (double)srcSize / fastestC / 1000000.);
|
DISPLAY("%9u (%4.3f),%7.1f MB/s, ", (U32)cSize, ratio, (double)srcSize / fastestC / 1000000.);
|
||||||
@ -521,9 +518,9 @@ static void playAround(FILE* f, winnerInfo_t* winners,
|
|||||||
ZSTD_CCtx* ctx)
|
ZSTD_CCtx* ctx)
|
||||||
{
|
{
|
||||||
int nbVariations = 0;
|
int nbVariations = 0;
|
||||||
clock_t const clockStart = clock();
|
UTIL_time_t const clockStart = UTIL_getTime();
|
||||||
|
|
||||||
while (BMK_clockSpan(clockStart) < g_maxVariationTime) {
|
while (UTIL_clockSpanMicro(clockStart) < g_maxVariationTime) {
|
||||||
ZSTD_compressionParameters p = params;
|
ZSTD_compressionParameters p = params;
|
||||||
|
|
||||||
if (nbVariations++ > g_maxNbVariations) break;
|
if (nbVariations++ > g_maxNbVariations) break;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
**************************************/
|
**************************************/
|
||||||
#include <stdlib.h> /* free */
|
#include <stdlib.h> /* free */
|
||||||
#include <stdio.h> /* fgets, sscanf */
|
#include <stdio.h> /* fgets, sscanf */
|
||||||
#include <time.h> /* clock_t, clock() */
|
|
||||||
#include <string.h> /* strcmp */
|
#include <string.h> /* strcmp */
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_maxCLevel */
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_maxCLevel */
|
||||||
@ -34,6 +33,7 @@
|
|||||||
#include "datagen.h" /* RDG_genBuffer */
|
#include "datagen.h" /* RDG_genBuffer */
|
||||||
#define XXH_STATIC_LINKING_ONLY
|
#define XXH_STATIC_LINKING_ONLY
|
||||||
#include "xxhash.h" /* XXH64_* */
|
#include "xxhash.h" /* XXH64_* */
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
@ -58,26 +58,25 @@ static const U32 prime2 = 2246822519U;
|
|||||||
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
#define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
|
||||||
static U32 g_displayLevel = 2;
|
static U32 g_displayLevel = 2;
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
#define SEC_TO_MICRO 1000000
|
||||||
if ((FUZ_GetClockSpan(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
{ g_displayClock = clock(); DISPLAY(__VA_ARGS__); \
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
if (g_displayLevel>=4) fflush(stderr); } }
|
|
||||||
static const clock_t g_refreshRate = CLOCKS_PER_SEC * 15 / 100;
|
|
||||||
static clock_t g_displayClock = 0;
|
|
||||||
|
|
||||||
static clock_t g_clockTime = 0;
|
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
||||||
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
||||||
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
|
if (g_displayLevel>=4) fflush(stderr); } }
|
||||||
|
|
||||||
|
static U64 g_clockTime = 0;
|
||||||
|
|
||||||
|
|
||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Fuzzer functions
|
* Fuzzer functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
static clock_t FUZ_GetClockSpan(clock_t clockStart)
|
|
||||||
{
|
|
||||||
return clock() - clockStart; /* works even when overflow. Max span ~ 30 mn */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! FUZ_rand() :
|
/*! FUZ_rand() :
|
||||||
@return : a 27 bits random value, from a 32-bits `seed`.
|
@return : a 27 bits random value, from a 32-bits `seed`.
|
||||||
`seed` is also modified */
|
`seed` is also modified */
|
||||||
@ -256,8 +255,6 @@ static size_t FUZ_randomLength(U32* seed, U32 maxLog)
|
|||||||
return FUZ_rLogLength(seed, logLength);
|
return FUZ_rLogLength(seed, logLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
|
|
||||||
|
|
||||||
#define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
#define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
|
||||||
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
|
||||||
|
|
||||||
@ -278,7 +275,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
U32 coreSeed = seed;
|
U32 coreSeed = seed;
|
||||||
ZBUFF_CCtx* zc;
|
ZBUFF_CCtx* zc;
|
||||||
ZBUFF_DCtx* zd;
|
ZBUFF_DCtx* zd;
|
||||||
clock_t startClock = clock();
|
UTIL_time_t startClock = UTIL_getTime();
|
||||||
|
|
||||||
/* allocations */
|
/* allocations */
|
||||||
zc = ZBUFF_createCCtx();
|
zc = ZBUFF_createCCtx();
|
||||||
@ -308,7 +305,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
|
|
||||||
/* test loop */
|
/* test loop */
|
||||||
for ( ; (testNb <= nbTests) || (FUZ_GetClockSpan(startClock) < g_clockTime) ; testNb++ ) {
|
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < g_clockTime) ; testNb++ ) {
|
||||||
U32 lseed;
|
U32 lseed;
|
||||||
const BYTE* srcBuffer;
|
const BYTE* srcBuffer;
|
||||||
const BYTE* dict;
|
const BYTE* dict;
|
||||||
@ -548,7 +545,7 @@ int main(int argc, const char** argv)
|
|||||||
}
|
}
|
||||||
if (*argument=='m') g_clockTime *=60, argument++;
|
if (*argument=='m') g_clockTime *=60, argument++;
|
||||||
if (*argument=='n') argument++;
|
if (*argument=='n') argument++;
|
||||||
g_clockTime *= CLOCKS_PER_SEC;
|
g_clockTime *= SEC_TO_MICRO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
**************************************/
|
**************************************/
|
||||||
#include <stdlib.h> /* free */
|
#include <stdlib.h> /* free */
|
||||||
#include <stdio.h> /* fgets, sscanf */
|
#include <stdio.h> /* fgets, sscanf */
|
||||||
#include <time.h> /* clock_t, clock() */
|
|
||||||
#include <string.h> /* strcmp */
|
#include <string.h> /* strcmp */
|
||||||
#include <assert.h> /* assert */
|
#include <assert.h> /* assert */
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
@ -37,6 +36,7 @@
|
|||||||
#define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
#define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
|
||||||
#include "xxhash.h" /* XXH64_* */
|
#include "xxhash.h" /* XXH64_* */
|
||||||
#include "seqgen.h"
|
#include "seqgen.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
/*-************************************
|
/*-************************************
|
||||||
@ -62,26 +62,25 @@ static const U32 prime32 = 2654435761U;
|
|||||||
if (g_displayLevel>=4) fflush(stderr); }
|
if (g_displayLevel>=4) fflush(stderr); }
|
||||||
static U32 g_displayLevel = 2;
|
static U32 g_displayLevel = 2;
|
||||||
|
|
||||||
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
#define SEC_TO_MICRO 1000000
|
||||||
if ((FUZ_GetClockSpan(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
static const U64 g_refreshRate = SEC_TO_MICRO / 6;
|
||||||
{ g_displayClock = clock(); DISPLAY(__VA_ARGS__); \
|
static UTIL_time_t g_displayClock = UTIL_TIME_INITIALIZER;
|
||||||
if (g_displayLevel>=4) fflush(stderr); } }
|
|
||||||
static const clock_t g_refreshRate = CLOCKS_PER_SEC / 6;
|
|
||||||
static clock_t g_displayClock = 0;
|
|
||||||
|
|
||||||
static clock_t g_clockTime = 0;
|
#define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
|
||||||
|
if ((UTIL_clockSpanMicro(g_displayClock) > g_refreshRate) || (g_displayLevel>=4)) \
|
||||||
|
{ g_displayClock = UTIL_getTime(); DISPLAY(__VA_ARGS__); \
|
||||||
|
if (g_displayLevel>=4) fflush(stderr); } }
|
||||||
|
|
||||||
|
static U64 g_clockTime = 0;
|
||||||
|
|
||||||
|
|
||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Fuzzer functions
|
* Fuzzer functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
static clock_t FUZ_GetClockSpan(clock_t clockStart)
|
|
||||||
{
|
|
||||||
return clock() - clockStart; /* works even when overflow. Max span ~ 30 mn */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! FUZ_rand() :
|
/*! FUZ_rand() :
|
||||||
@return : a 27 bits random value, from a 32-bits `seed`.
|
@return : a 27 bits random value, from a 32-bits `seed`.
|
||||||
`seed` is also modified */
|
`seed` is also modified */
|
||||||
@ -815,8 +814,6 @@ static size_t FUZ_randomLength(U32* seed, U32 maxLog)
|
|||||||
return FUZ_rLogLength(seed, logLength);
|
return FUZ_rLogLength(seed, logLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
|
|
||||||
|
|
||||||
/* Return value in range minVal <= v <= maxVal */
|
/* Return value in range minVal <= v <= maxVal */
|
||||||
static U32 FUZ_randomClampedLength(U32* seed, U32 minVal, U32 maxVal)
|
static U32 FUZ_randomClampedLength(U32* seed, U32 minVal, U32 maxVal)
|
||||||
{
|
{
|
||||||
@ -842,7 +839,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
ZSTD_CStream* zc = ZSTD_createCStream(); /* will be re-created sometimes */
|
ZSTD_CStream* zc = ZSTD_createCStream(); /* will be re-created sometimes */
|
||||||
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be re-created sometimes */
|
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be re-created sometimes */
|
||||||
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
||||||
clock_t const startClock = clock();
|
UTIL_time_t const startClock = UTIL_getTime();
|
||||||
const BYTE* dict = NULL; /* can keep same dict on 2 consecutive tests */
|
const BYTE* dict = NULL; /* can keep same dict on 2 consecutive tests */
|
||||||
size_t dictSize = 0;
|
size_t dictSize = 0;
|
||||||
U32 oldTestLog = 0;
|
U32 oldTestLog = 0;
|
||||||
@ -872,7 +869,7 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
|
|
||||||
/* test loop */
|
/* test loop */
|
||||||
for ( ; (testNb <= nbTests) || (FUZ_GetClockSpan(startClock) < g_clockTime) ; testNb++ ) {
|
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < g_clockTime) ; testNb++ ) {
|
||||||
U32 lseed;
|
U32 lseed;
|
||||||
const BYTE* srcBuffer;
|
const BYTE* srcBuffer;
|
||||||
size_t totalTestSize, totalGenSize, cSize;
|
size_t totalTestSize, totalGenSize, cSize;
|
||||||
@ -1092,7 +1089,7 @@ static int fuzzerTests_MT(U32 seed, U32 nbTests, unsigned startTest, double comp
|
|||||||
ZSTDMT_CCtx* zc = ZSTDMT_createCCtx(nbThreads); /* will be reset sometimes */
|
ZSTDMT_CCtx* zc = ZSTDMT_createCCtx(nbThreads); /* will be reset sometimes */
|
||||||
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be reset sometimes */
|
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be reset sometimes */
|
||||||
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
||||||
clock_t const startClock = clock();
|
UTIL_time_t const startClock = UTIL_getTime();
|
||||||
const BYTE* dict=NULL; /* can keep same dict on 2 consecutive tests */
|
const BYTE* dict=NULL; /* can keep same dict on 2 consecutive tests */
|
||||||
size_t dictSize = 0;
|
size_t dictSize = 0;
|
||||||
U32 oldTestLog = 0;
|
U32 oldTestLog = 0;
|
||||||
@ -1123,7 +1120,7 @@ static int fuzzerTests_MT(U32 seed, U32 nbTests, unsigned startTest, double comp
|
|||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
|
|
||||||
/* test loop */
|
/* test loop */
|
||||||
for ( ; (testNb <= nbTests) || (FUZ_GetClockSpan(startClock) < g_clockTime) ; testNb++ ) {
|
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < g_clockTime) ; testNb++ ) {
|
||||||
U32 lseed;
|
U32 lseed;
|
||||||
const BYTE* srcBuffer;
|
const BYTE* srcBuffer;
|
||||||
size_t totalTestSize, totalGenSize, cSize;
|
size_t totalTestSize, totalGenSize, cSize;
|
||||||
@ -1364,7 +1361,7 @@ static int fuzzerTests_newAPI(U32 seed, U32 nbTests, unsigned startTest, double
|
|||||||
ZSTD_CCtx* zc = ZSTD_createCCtx(); /* will be reset sometimes */
|
ZSTD_CCtx* zc = ZSTD_createCCtx(); /* will be reset sometimes */
|
||||||
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be reset sometimes */
|
ZSTD_DStream* zd = ZSTD_createDStream(); /* will be reset sometimes */
|
||||||
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
ZSTD_DStream* const zd_noise = ZSTD_createDStream();
|
||||||
clock_t const startClock = clock();
|
UTIL_time_t const startClock = UTIL_getTime();
|
||||||
const BYTE* dict = NULL; /* can keep same dict on 2 consecutive tests */
|
const BYTE* dict = NULL; /* can keep same dict on 2 consecutive tests */
|
||||||
size_t dictSize = 0;
|
size_t dictSize = 0;
|
||||||
U32 oldTestLog = 0;
|
U32 oldTestLog = 0;
|
||||||
@ -1397,7 +1394,7 @@ static int fuzzerTests_newAPI(U32 seed, U32 nbTests, unsigned startTest, double
|
|||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
|
|
||||||
/* test loop */
|
/* test loop */
|
||||||
for ( ; (testNb <= nbTests) || (FUZ_GetClockSpan(startClock) < g_clockTime) ; testNb++ ) {
|
for ( ; (testNb <= nbTests) || (UTIL_clockSpanMicro(startClock) < g_clockTime) ; testNb++ ) {
|
||||||
U32 lseed;
|
U32 lseed;
|
||||||
const BYTE* srcBuffer;
|
const BYTE* srcBuffer;
|
||||||
size_t totalTestSize, totalGenSize, cSize;
|
size_t totalTestSize, totalGenSize, cSize;
|
||||||
@ -1772,7 +1769,7 @@ int main(int argc, const char** argv)
|
|||||||
g_clockTime *=60, argument++;
|
g_clockTime *=60, argument++;
|
||||||
if (*argument=='n') argument++; /* -T1mn == -T60 */
|
if (*argument=='n') argument++; /* -T1mn == -T60 */
|
||||||
} else if (*argument=='s') argument++; /* -T10s == -T10 */
|
} else if (*argument=='s') argument++; /* -T10s == -T10 */
|
||||||
g_clockTime *= CLOCKS_PER_SEC;
|
g_clockTime *= SEC_TO_MICRO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's': /* manually select seed */
|
case 's': /* manually select seed */
|
||||||
|
Reference in New Issue
Block a user