blob: 658f6687f43c597361d3387415311e1018670cee [file] [log] [blame]
tanjent@gmail.com7e5c3632010-11-02 00:50:04 +00001#include <stdio.h>
2
3#include <time.h>
4#include "hashes.h"
5#include "tests.h"
6
7#include <windows.h>
8
9#pragma warning(disable:4702)
10
11//----------------------------------------------------------------------------
12
13template < typename hashtype >
14void test ( hashfunc<hashtype> hash, const char * hashname )
15{
16 printf("Testing %s\n",hashname);
17
18 //const int hbytes = sizeof(hashtype);
19 //const int hbits = hbytes * 8;
20
21 TwiddleTest(hash);
22 AlignmentTest(hash);
23 AppendedZeroesTest(hash);
24 QuickBrownFox(hash);
25 printf("\n");
26
27 BulkSpeedTest(hash);
28
29 TinySpeedTest<hashtype,4>(hash);
30 TinySpeedTest<hashtype,5>(hash);
31 TinySpeedTest<hashtype,6>(hash);
32 TinySpeedTest<hashtype,7>(hash);
33 TinySpeedTest<hashtype,8>(hash);
34 TinySpeedTest<hashtype,256>(hash);
35 printf("\n");
36
37 // # of bytes in the cycle must be at least # of bytes in the hash output
38
39 //CycleTest<hashtype>(hash,sizeof(hashtype)+0,8,10000000);
40 //CycleTest<hashtype>(hash,sizeof(hashtype)+1,8,10000000);
41 //CycleTest<hashtype>(hash,sizeof(hashtype)+2,8,10000000);
42 //CycleTest<hashtype>(hash,sizeof(hashtype)+3,8,10000000);
43 //CycleTest<hashtype>(hash,sizeof(hashtype)+4,8,10000000);
44
45 printf("\n");
46
47 /*
48 DiffTest< Blob<64>, hashtype >(hash,5,1000);
49 DiffTest< Blob<128>, hashtype >(hash,4,1000);
50 DiffTest< Blob<256>, hashtype >(hash,3,1000);
51
52 printf("\n");
53
54 AvalancheTest(hash);
55 */
56
57 SparseKeyTest(hash,false);
58
59 //DictionaryTest(hash);
60 //BitrangeKeysetTest(hash,false);
61 //TextKeyTest(hash.m_hash);
62}
63
64//-----------------------------------------------------------------------------
65
66void optimize_fmix64 ( void );
67
68void main ( void )
69{
70 SetProcessAffinityMask(GetCurrentProcess(),2);
71
72 int a = clock();
73
74#if 0
75
76 optimize_fmix64();
77
78 //scratchmain();
79
80#else
81
82 //----------
83
84 //test<uint32_t> ( md5_32, "MD5, first 32 bits" );
85 //test<uint32_t> ( lookup3_test, "Jenkins lookup3" );
86 //test<uint32_t> ( SuperFastHash, "SuperFastHash" );
87 //test<uint32_t> ( MurmurHash2_test, "MurmurHash2 32-bit" );
88 //test<uint32_t> ( MurmurHash2A_test, "MurmurHash2 32-bit" );
89 //test<uint32_t> ( FNV, "FNV 32-bit" );
90 //test<uint32_t> ( crc32, "CRC-32" );
91 //test<uint32_t> ( DoNothingHash, "MurmurHash3 32-bit" );
92
93 //test<uint32_t> ( MurmurHash3_x86_32, "MurmurHash3 32-bit" );
94 test<uint64_t> ( MurmurHash3_x86_64, "MurmurHash3 64-bit" );
95 //test<k128> ( MurmurHash3_128, "MurmurHash3 128-bit" );
96
97 //test<uint32_t> ( MurmurHash3x64_32, "MurmurHash3 32-bit" );
98
99#endif
100
101 int b = clock();
102
103 printf("time %d\n",b-a);
104}