improved timer accuracy
This commit is contained in:
parent
5b15865413
commit
1c1e6916e4
@ -687,12 +687,16 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
|
|||||||
offset = 1-offset;
|
offset = 1-offset;
|
||||||
if (offset != 0)
|
if (offset != 0)
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
size_t temp = seqState->prevOffset[offset];
|
size_t temp = seqState->prevOffset[offset];
|
||||||
if (offset != 1) {
|
if (offset != 1) {
|
||||||
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
if (offset == 3) seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
seqState->prevOffset[2] = seqState->prevOffset[1];
|
seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
}
|
}
|
||||||
offset = temp;
|
offset = temp;
|
||||||
|
#else
|
||||||
|
offset = seqState->prevOffset[1];
|
||||||
|
#endif
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
seqState->prevOffset[0] = offset;
|
seqState->prevOffset[0] = offset;
|
||||||
}
|
}
|
||||||
@ -701,8 +705,8 @@ static void ZSTD_decodeSequence(seq_t* seq, seqState_t* seqState, const U32 mls)
|
|||||||
} else {
|
} else {
|
||||||
offset -= ZSTD_REP_MOVE;
|
offset -= ZSTD_REP_MOVE;
|
||||||
#if 0
|
#if 0
|
||||||
seqState->prevOffset[3] = seqState->prevOffset[2];
|
// seqState->prevOffset[3] = seqState->prevOffset[2];
|
||||||
seqState->prevOffset[2] = seqState->prevOffset[1];
|
// seqState->prevOffset[2] = seqState->prevOffset[1];
|
||||||
seqState->prevOffset[1] = seqState->prevOffset[0];
|
seqState->prevOffset[1] = seqState->prevOffset[0];
|
||||||
seqState->prevOffset[0] = offset;
|
seqState->prevOffset[0] = offset;
|
||||||
#else
|
#else
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
#else
|
#else
|
||||||
#define ZSTD_REP_NUM 1
|
#define ZSTD_REP_NUM 1
|
||||||
#define ZSTD_REP_INIT 2
|
#define ZSTD_REP_INIT 2
|
||||||
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
#define ZSTD_REP_MOVE 0//(ZSTD_REP_NUM-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define KB *(1 <<10)
|
#define KB *(1 <<10)
|
||||||
|
@ -44,13 +44,22 @@
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Includes
|
* Includes
|
||||||
***************************************/
|
***************************************/
|
||||||
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64)
|
||||||
|
#define WINDOWS
|
||||||
|
#endif
|
||||||
#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 <sys/types.h> /* stat64 */
|
#include <sys/types.h> /* stat64 */
|
||||||
#include <sys/stat.h> /* stat64 */
|
#include <sys/stat.h> /* stat64 */
|
||||||
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
#include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#define mili_sleep(mili) Sleep(mili)
|
||||||
|
#else
|
||||||
|
#define mili_sleep(mili) usleep(mili*1000)
|
||||||
|
#include <sys/resource.h> /* setpriority */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* sleep : posix - windows - others */
|
/* sleep : posix - windows - others */
|
||||||
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
|
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -283,6 +292,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
memset(compressedBuffer, 0xE5, maxCompressedSize); /* warm up and erase result buffer */
|
memset(compressedBuffer, 0xE5, maxCompressedSize); /* warm up and erase result buffer */
|
||||||
|
|
||||||
nbLoops = 0;
|
nbLoops = 0;
|
||||||
|
mili_sleep(1); // give processor to other processes
|
||||||
clockStart = clock();
|
clockStart = clock();
|
||||||
while (clock() == clockStart);
|
while (clock() == clockStart);
|
||||||
clockStart = clock();
|
clockStart = clock();
|
||||||
@ -313,6 +323,7 @@ static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
|
|||||||
memset(resultBuffer, 0xD6, srcSize); /* warm result buffer */
|
memset(resultBuffer, 0xD6, srcSize); /* warm result buffer */
|
||||||
|
|
||||||
nbLoops = 0;
|
nbLoops = 0;
|
||||||
|
mili_sleep(1); // give processor to other processes
|
||||||
clockStart = clock();
|
clockStart = clock();
|
||||||
while (clock() == clockStart);
|
while (clock() == clockStart);
|
||||||
clockStart = clock();
|
clockStart = clock();
|
||||||
@ -413,6 +424,11 @@ static void BMK_benchCLevel(void* srcBuffer, size_t benchedSize,
|
|||||||
{
|
{
|
||||||
benchResult_t result, total;
|
benchResult_t result, total;
|
||||||
int l;
|
int l;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
|
||||||
|
#else
|
||||||
|
setpriority(PRIO_PROCESS, 0, -20);
|
||||||
|
#endif
|
||||||
|
|
||||||
const char* pch = strrchr(displayName, '\\'); /* Windows */
|
const char* pch = strrchr(displayName, '\\'); /* Windows */
|
||||||
if (!pch) pch = strrchr(displayName, '/'); /* Linux */
|
if (!pch) pch = strrchr(displayName, '/'); /* Linux */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user