Data Structures | Macros | Typedefs | Functions | Variables
Test-HashingSpeed.C File Reference
Include dependency graph for Test-HashingSpeed.C:

Go to the source code of this file.

Data Structures

struct  tagtest
 

Macros

#define HASH_LITTLE_ENDIAN   0
 
#define HASH_BIG_ENDIAN   0
 
#define rot(x, k)   (((x)<<(k)) | ((x)>>(32-(k))))
 
#define mix(a, b, c)
 
#define final(a, b, c)
 
#define CRC32POLYNOMIAL   0x04c11db7L
 
#define get16bits(d)
 
#define BUFF_SZ   (128*2)
 
#define NTESTS   5000000
 

Typedefs

typedef uint32_t(* hashFn) (const char *s, int len)
 

Functions

uint32_t hashword (const uint32_t *k, size_t length, uint32_t initval)
 
void hashword2 (const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb)
 
uint32_t hashlittle (const void *key, size_t length, uint32_t initval)
 
void hashlittle2 (const void *key, size_t length, uint32_t *pc, uint32_t *pb)
 
uint32_t hashbig (const void *key, size_t length, uint32_t initval)
 
uint32_t hashLookup3Orig (const char *k, int length)
 
uint32_t hashLookup3 (const char *k, int length)
 
static uint32_t GetCRC16Update (uint32_t start_crc, const char *data_stream, int length)
 
uint32_t GetCRC16 (const char *data_stream, int length)
 
static void GenerateCRC32Table (void)
 
static uint32_t UpdateCRC32 (uint32_t crc_accum, const char *data_blk_ptr, int data_blk_size)
 
uint32_t GetCRC32 (const char *data_stream, int length)
 
uint32_t GetCRC32PH (const char *data_blk_ptr, int data_blk_size)
 
uint32_t FNVHash (const char *data, int len)
 
uint32_t oneAtATimeHash (const char *s, int len)
 
uint32_t oneAtATimeHashPH (const char *s, int len)
 
uint32_t SuperFastHash (const char *data, int len)
 
uint32_t alphaNumHash (const char *s, int len)
 
uint32_t bernstein (const char *s, int len)
 
uint32_t stroustrup (const char *s, int len)
 
double test (hashFn hash)
 
int main ()
 

Variables

static uint32_t crc_16_table [16]
 
static uint32_t crc_table [256]
 
struct tagtest tests []
 

Macro Definition Documentation

◆ HASH_LITTLE_ENDIAN

#define HASH_LITTLE_ENDIAN   0

Definition at line 77 of file Test-HashingSpeed.C.

◆ HASH_BIG_ENDIAN

#define HASH_BIG_ENDIAN   0

Definition at line 78 of file Test-HashingSpeed.C.

◆ rot

#define rot (   x,
  k 
)    (((x)<<(k)) | ((x)>>(32-(k))))

Definition at line 81 of file Test-HashingSpeed.C.

◆ mix

#define mix (   a,
  b,
 
)
Value:
{ \
a -= c; a ^= rot(c, 4); c += b; \
b -= a; b ^= rot(a, 6); a += c; \
c -= b; c ^= rot(b, 8); b += a; \
a -= c; a ^= rot(c,16); c += b; \
b -= a; b ^= rot(a,19); a += c; \
c -= b; c ^= rot(b, 4); b += a; \
}

Definition at line 127 of file Test-HashingSpeed.C.

◆ final

#define final (   a,
  b,
 
)
Value:
{ \
c ^= b; c -= rot(b, 14); \
a ^= c; a -= rot(c, 11); \
b ^= a; b -= rot(a, 25); \
c ^= b; c -= rot(b, 16); \
a ^= c; a -= rot(c, 4); \
b ^= a; b -= rot(a, 14); \
c ^= b; c -= rot(b, 24); \
}

Definition at line 162 of file Test-HashingSpeed.C.

◆ CRC32POLYNOMIAL

#define CRC32POLYNOMIAL   0x04c11db7L

Definition at line 796 of file Test-HashingSpeed.C.

◆ get16bits

#define get16bits (   d)
Value:
((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
+(uint32_t)(((const uint8_t *)(d))[0]) )

Definition at line 938 of file Test-HashingSpeed.C.

◆ BUFF_SZ

#define BUFF_SZ   (128*2)

Definition at line 1033 of file Test-HashingSpeed.C.

◆ NTESTS

#define NTESTS   5000000

Definition at line 1034 of file Test-HashingSpeed.C.

Typedef Documentation

◆ hashFn

typedef uint32_t(* hashFn) (const char *s, int len)

Definition at line 1031 of file Test-HashingSpeed.C.

Function Documentation

◆ hashword()

uint32_t hashword ( const uint32_t *  k,
size_t  length,
uint32_t  initval 
)

◆ hashword2()

void hashword2 ( const uint32_t *  k,
size_t  length,
uint32_t *  pc,
uint32_t *  pb 
)

◆ hashlittle()

uint32_t hashlittle ( const void *  key,
size_t  length,
uint32_t  initval 
)

Definition at line 295 of file Test-HashingSpeed.C.

References Foam::constant::physicoChemical::b, Foam::constant::universal::c, HASH_LITTLE_ENDIAN, k, and mix.

Referenced by hashLookup3Orig().

Here is the caller graph for this function:

◆ hashlittle2()

void hashlittle2 ( const void *  key,
size_t  length,
uint32_t *  pc,
uint32_t *  pb 
)

◆ hashbig()

uint32_t hashbig ( const void *  key,
size_t  length,
uint32_t  initval 
)

◆ hashLookup3Orig()

uint32_t hashLookup3Orig ( const char *  k,
int  length 
)

Definition at line 690 of file Test-HashingSpeed.C.

References hashlittle(), and k.

Here is the call graph for this function:

◆ hashLookup3()

uint32_t hashLookup3 ( const char *  k,
int  length 
)

Definition at line 694 of file Test-HashingSpeed.C.

References Foam::Hasher(), and k.

Here is the call graph for this function:

◆ GetCRC16Update()

static uint32_t GetCRC16Update ( uint32_t  start_crc,
const char *  data_stream,
int  length 
)
static

Definition at line 719 of file Test-HashingSpeed.C.

References crc_16_table.

Referenced by GetCRC16().

Here is the caller graph for this function:

◆ GetCRC16()

uint32_t GetCRC16 ( const char *  data_stream,
int  length 
)

Definition at line 747 of file Test-HashingSpeed.C.

References GetCRC16Update().

Here is the call graph for this function:

◆ GenerateCRC32Table()

static void GenerateCRC32Table ( void  )
static

Definition at line 798 of file Test-HashingSpeed.C.

References CRC32POLYNOMIAL, and crc_table.

Referenced by main().

Here is the caller graph for this function:

◆ UpdateCRC32()

static uint32_t UpdateCRC32 ( uint32_t  crc_accum,
const char *  data_blk_ptr,
int  data_blk_size 
)
static

Definition at line 819 of file Test-HashingSpeed.C.

References crc_table.

Referenced by GetCRC32().

Here is the caller graph for this function:

◆ GetCRC32()

uint32_t GetCRC32 ( const char *  data_stream,
int  length 
)

Definition at line 834 of file Test-HashingSpeed.C.

References UpdateCRC32().

Here is the call graph for this function:

◆ GetCRC32PH()

uint32_t GetCRC32PH ( const char *  data_blk_ptr,
int  data_blk_size 
)

Definition at line 843 of file Test-HashingSpeed.C.

References crc_table.

◆ FNVHash()

uint32_t FNVHash ( const char *  data,
int  len 
)

Definition at line 864 of file Test-HashingSpeed.C.

◆ oneAtATimeHash()

uint32_t oneAtATimeHash ( const char *  s,
int  len 
)

Definition at line 881 of file Test-HashingSpeed.C.

References s().

Here is the call graph for this function:

◆ oneAtATimeHashPH()

uint32_t oneAtATimeHashPH ( const char *  s,
int  len 
)

Definition at line 898 of file Test-HashingSpeed.C.

References s().

Here is the call graph for this function:

◆ SuperFastHash()

uint32_t SuperFastHash ( const char *  data,
int  len 
)

Definition at line 942 of file Test-HashingSpeed.C.

References get16bits.

◆ alphaNumHash()

uint32_t alphaNumHash ( const char *  s,
int  len 
)

Definition at line 995 of file Test-HashingSpeed.C.

References Foam::constant::universal::h, and s().

Here is the call graph for this function:

◆ bernstein()

uint32_t bernstein ( const char *  s,
int  len 
)

Definition at line 1005 of file Test-HashingSpeed.C.

References Foam::constant::universal::h, and s().

Here is the call graph for this function:

◆ stroustrup()

uint32_t stroustrup ( const char *  s,
int  len 
)

Definition at line 1017 of file Test-HashingSpeed.C.

References Foam::constant::universal::h, and s().

Here is the call graph for this function:

◆ test()

double test ( hashFn  hash)

Definition at line 1036 of file Test-HashingSpeed.C.

References BUFF_SZ, Foam::constant::physicoChemical::c1, and NTESTS.

Referenced by rotorDiskSource::createCoordinateSystem(), and main().

Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 1066 of file Test-HashingSpeed.C.

References GenerateCRC32Table(), Foam::name(), tagtest::name, tagtest::res, test(), and tests.

Here is the call graph for this function:

Variable Documentation

◆ crc_16_table

uint32_t crc_16_table[16]
static
Initial value:
= {
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400
}

Definition at line 702 of file Test-HashingSpeed.C.

Referenced by GetCRC16Update().

◆ crc_table

uint32_t crc_table[256]
static

Definition at line 753 of file Test-HashingSpeed.C.

Referenced by GenerateCRC32Table(), GetCRC32PH(), and UpdateCRC32().

◆ tests

struct tagtest tests[]
Initial value:
= {
{ 0.0, "FNVHash\t\t", FNVHash },
{ 0.0, "bernstein\t", bernstein },
{ 0.0, "stroustrup\t", stroustrup },
{ 0.0, "hashLookup3\t", hashLookup3 },
{ 0.0, "hashLookup3Orig\t", hashLookup3Orig },
{ 0.0, "SuperFastHash\t", SuperFastHash },
{ 0.0, NULL, NULL }
}

Referenced by main().

stroustrup
uint32_t stroustrup(const char *s, int len)
Definition: Test-HashingSpeed.C:1017
hashLookup3Orig
uint32_t hashLookup3Orig(const char *k, int length)
Definition: Test-HashingSpeed.C:690
SuperFastHash
uint32_t SuperFastHash(const char *data, int len)
Definition: Test-HashingSpeed.C:942
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
rot
#define rot(x, k)
Definition: Test-HashingSpeed.C:81
FNVHash
uint32_t FNVHash(const char *data, int len)
Definition: Test-HashingSpeed.C:864
bernstein
uint32_t bernstein(const char *s, int len)
Definition: Test-HashingSpeed.C:1005
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
hashLookup3
uint32_t hashLookup3(const char *k, int length)
Definition: Test-HashingSpeed.C:694