tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 1 | #include "Platform.h"
|
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 2 | #include "Hashes.h"
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 3 | #include "KeysetTest.h"
|
| 4 | #include "SpeedTest.h"
|
| 5 | #include "AvalancheTest.h"
|
| 6 | #include "DifferentialTest.h"
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 7 |
|
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 8 | #include <stdio.h>
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 9 | #include <time.h>
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 10 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 11 | //-----------------------------------------------------------------------------
|
| 12 | // Configuration. TODO - move these to command-line flags
|
| 13 |
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 14 | bool g_testAll = false;
|
| 15 |
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 16 | bool g_testSanity = false;
|
| 17 | bool g_testSpeed = false;
|
| 18 | bool g_testDiff = false;
|
| 19 | bool g_testAvalanche = false;
|
| 20 | bool g_testCyclic = false;
|
| 21 | bool g_testSparse = false;
|
| 22 | bool g_testPermutation = false;
|
| 23 | bool g_testWindow = false;
|
| 24 | bool g_testText = false;
|
| 25 | bool g_testZeroes = false;
|
| 26 | bool g_testSeed = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 27 |
|
tanjent@gmail.com | f67ce94 | 2011-03-14 09:11:18 +0000 | [diff] [blame] | 28 | //-----------------------------------------------------------------------------
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 29 | // This is the list of all hashes that SMHasher can test.
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 30 |
|
| 31 | struct HashInfo
|
| 32 | {
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 33 | pfHash hash;
|
| 34 | int hashbits;
|
| 35 | uint32_t verification;
|
| 36 | const char * name;
|
| 37 | const char * desc;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 38 | };
|
| 39 |
|
| 40 | HashInfo g_hashes[] =
|
| 41 | {
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 42 | { DoNothingHash, 32, 0x00000000, "donothing32", "Do-Nothing function (only valid for measuring call overhead)" },
|
| 43 | { DoNothingHash, 64, 0x00000000, "donothing64", "Do-Nothing function (only valid for measuring call overhead)" },
|
| 44 | { DoNothingHash, 128, 0x00000000, "donothing128", "Do-Nothing function (only valid for measuring call overhead)" },
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 45 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 46 | { crc32, 32, 0x5C7DDD1F, "crc32", "CRC-32" },
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 47 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 48 | { md5_32, 32, 0xC10C356B, "md5_32a", "MD5, first 32 bits of result" },
|
| 49 | { sha1_32a, 32, 0xF9376EA7, "sha1_32a", "SHA1, first 32 bits of result" },
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 50 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 51 | { FNV, 32, 0x2B377407, "FNV", "Fowler-Noll-Vo hash, 32-bit" },
|
| 52 | { lookup3_test, 32, 0xDEC6FD2F, "lookup3", "Bob Jenkins' lookup3" },
|
| 53 | { SuperFastHash, 32, 0x980ACD1D, "superfast", "Paul Hsieh's SuperFastHash" },
|
tanjent@gmail.com | 3ee4561 | 2011-03-21 19:33:01 +0000 | [diff] [blame] | 54 | { MurmurOAAT_test, 32, 0xF5AC8D0D, "MurmurOAAT", "Murmur one-at-a-time" },
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 55 |
|
| 56 | // MurmurHash2
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 57 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 58 | { MurmurHash2_test, 32, 0xA6D95DE6, "Murmur2", "MurmurHash2 for x86, 32-bit" },
|
| 59 | { MurmurHash2A_test, 32, 0xB79DC030, "Murmur2A", "MurmurHash2A for x86, 32-bit" },
|
| 60 | { MurmurHash64A_test, 64, 0xDBD7FF4B, "Murmur2B", "MurmurHash2 for x64, 64-bit" },
|
| 61 | { MurmurHash64B_test, 64, 0x3B861F71, "Murmur2C", "MurmurHash2 for x86, 64-bit" },
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 62 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 63 | // MurmurHash3
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 64 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 65 | { MurmurHash3_x86_32, 32, 0x3B75AFFD, "Murmur3A", "MurmurHash3 for x86, 32-bit" },
|
| 66 | { MurmurHash3_x86_128, 128, 0x78C7F0DB, "Murmur3C", "MurmurHash3 for x86, 128-bit" },
|
| 67 | { MurmurHash3_x64_128, 128, 0x54667393, "Murmur3F", "MurmurHash3 for x64, 128-bit" },
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 68 |
|
| 69 | };
|
| 70 |
|
| 71 | HashInfo * findHash ( const char * name )
|
| 72 | {
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 73 | for(int i = 0; i < sizeof(g_hashes) / sizeof(HashInfo); i++)
|
| 74 | {
|
| 75 | if(_stricmp(name,g_hashes[i].name) == 0) return &g_hashes[i];
|
| 76 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 77 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 78 | return NULL;
|
| 79 | }
|
| 80 |
|
| 81 | //-----------------------------------------------------------------------------
|
| 82 | // Self-test on startup - verify that all installed hashes work correctly.
|
| 83 |
|
| 84 | void SelfTest ( void )
|
| 85 | {
|
| 86 | bool pass = true;
|
| 87 |
|
| 88 | for(int i = 0; i < sizeof(g_hashes) / sizeof(HashInfo); i++)
|
| 89 | {
|
| 90 | HashInfo * info = & g_hashes[i];
|
| 91 |
|
| 92 | pass &= VerificationTest(info->hash,info->hashbits,info->verification,false);
|
| 93 | }
|
| 94 |
|
| 95 | if(!pass)
|
| 96 | {
|
| 97 | printf("Self-test FAILED!\n");
|
| 98 |
|
| 99 | for(int i = 0; i < sizeof(g_hashes) / sizeof(HashInfo); i++)
|
| 100 | {
|
| 101 | HashInfo * info = & g_hashes[i];
|
| 102 |
|
| 103 | pass &= VerificationTest(info->hash,info->hashbits,info->verification,true);
|
| 104 | }
|
| 105 |
|
| 106 | exit(1);
|
| 107 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 108 | }
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 109 |
|
| 110 | //----------------------------------------------------------------------------
|
| 111 |
|
| 112 | template < typename hashtype >
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 113 | void test ( hashfunc<hashtype> hash, HashInfo * info )
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 114 | {
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 115 | const int hashbits = sizeof(hashtype) * 8;
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 116 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 117 | printf("-------------------------------------------------------------------------------\n");
|
| 118 | printf("--- Testing %s\n\n",info->name);
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 119 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 120 | //-----------------------------------------------------------------------------
|
| 121 | // Sanity tests
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 122 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 123 | if(g_testSanity || g_testAll)
|
| 124 | {
|
| 125 | printf("[[[ Sanity Tests ]]]\n\n");
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 126 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 127 | VerificationTest(hash,hashbits,info->verification,true);
|
| 128 | SanityTest(hash,hashbits);
|
| 129 | AppendedZeroesTest(hash,hashbits);
|
| 130 | printf("\n");
|
| 131 | }
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 132 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 133 | //-----------------------------------------------------------------------------
|
| 134 | // Speed tests
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 135 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 136 | if(g_testSpeed || g_testAll)
|
| 137 | {
|
| 138 | printf("[[[ Speed Tests ]]]\n\n");
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 139 |
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 140 | BulkSpeedTest(info->hash,info->verification);
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 141 | printf("\n");
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 142 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 143 | for(int i = 1; i < 32; i++)
|
| 144 | {
|
| 145 | double cycles;
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 146 |
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 147 | TinySpeedTest(hashfunc<hashtype>(info->hash),sizeof(hashtype),i,info->verification,true,cycles);
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 148 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 149 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 150 | printf("\n");
|
| 151 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 152 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 153 | //-----------------------------------------------------------------------------
|
| 154 | // Differential tests
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 155 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 156 | if(g_testDiff || g_testAll)
|
| 157 | {
|
| 158 | printf("[[[ Differential Tests ]]]\n\n");
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 159 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 160 | bool result = true;
|
| 161 | bool dumpCollisions = false;
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 162 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 163 | result &= DiffTest< Blob<64>, hashtype >(hash,5,1000,dumpCollisions);
|
| 164 | result &= DiffTest< Blob<128>, hashtype >(hash,4,1000,dumpCollisions);
|
| 165 | result &= DiffTest< Blob<256>, hashtype >(hash,3,1000,dumpCollisions);
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 166 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 167 | if(!result) printf("*********FAIL*********\n");
|
| 168 | printf("\n");
|
| 169 | }
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 170 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 171 | //-----------------------------------------------------------------------------
|
| 172 | // Avalanche tests
|
| 173 |
|
| 174 | if(g_testAvalanche || g_testAll)
|
| 175 | {
|
| 176 | printf("[[[ Avalanche Tests ]]]\n\n");
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 177 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 178 | bool result = true;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 179 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 180 | result &= AvalancheTest< Blob< 32>, hashtype > (hash,300000);
|
| 181 | result &= AvalancheTest< Blob< 40>, hashtype > (hash,300000);
|
| 182 | result &= AvalancheTest< Blob< 48>, hashtype > (hash,300000);
|
| 183 | result &= AvalancheTest< Blob< 56>, hashtype > (hash,300000);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 184 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 185 | result &= AvalancheTest< Blob< 64>, hashtype > (hash,300000);
|
| 186 | result &= AvalancheTest< Blob< 72>, hashtype > (hash,300000);
|
| 187 | result &= AvalancheTest< Blob< 80>, hashtype > (hash,300000);
|
| 188 | result &= AvalancheTest< Blob< 88>, hashtype > (hash,300000);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 189 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 190 | result &= AvalancheTest< Blob< 96>, hashtype > (hash,300000);
|
| 191 | result &= AvalancheTest< Blob<104>, hashtype > (hash,300000);
|
| 192 | result &= AvalancheTest< Blob<112>, hashtype > (hash,300000);
|
| 193 | result &= AvalancheTest< Blob<120>, hashtype > (hash,300000);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 194 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 195 | result &= AvalancheTest< Blob<128>, hashtype > (hash,300000);
|
| 196 | result &= AvalancheTest< Blob<136>, hashtype > (hash,300000);
|
| 197 | result &= AvalancheTest< Blob<144>, hashtype > (hash,300000);
|
| 198 | result &= AvalancheTest< Blob<152>, hashtype > (hash,300000);
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 199 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 200 | if(!result) printf("*********FAIL*********\n");
|
| 201 | printf("\n");
|
| 202 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 203 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 204 | //-----------------------------------------------------------------------------
|
| 205 | // Keyset 'Cyclic'
|
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 206 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 207 | if(g_testCyclic || g_testAll)
|
| 208 | {
|
| 209 | printf("[[[ Keyset 'Cyclic' Tests ]]]\n\n");
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 210 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 211 | bool result = true;
|
| 212 | bool drawDiagram = false;
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 213 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 214 | result &= CyclicKeyTest<hashtype>(hash,sizeof(hashtype)+0,8,10000000,drawDiagram);
|
| 215 | result &= CyclicKeyTest<hashtype>(hash,sizeof(hashtype)+1,8,10000000,drawDiagram);
|
| 216 | result &= CyclicKeyTest<hashtype>(hash,sizeof(hashtype)+2,8,10000000,drawDiagram);
|
| 217 | result &= CyclicKeyTest<hashtype>(hash,sizeof(hashtype)+3,8,10000000,drawDiagram);
|
| 218 | result &= CyclicKeyTest<hashtype>(hash,sizeof(hashtype)+4,8,10000000,drawDiagram);
|
| 219 |
|
| 220 | if(!result) printf("*********FAIL*********\n");
|
| 221 | printf("\n");
|
| 222 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 223 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 224 | //-----------------------------------------------------------------------------
|
| 225 | // Keyset 'Sparse'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 226 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 227 | if(g_testSparse || g_testAll)
|
| 228 | {
|
| 229 | printf("[[[ Keyset 'Sparse' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 230 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 231 | bool result = true;
|
| 232 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 233 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 234 | result &= SparseKeyTest< 32,hashtype>(hash,6,true,true,true,drawDiagram);
|
| 235 | result &= SparseKeyTest< 40,hashtype>(hash,6,true,true,true,drawDiagram);
|
| 236 | result &= SparseKeyTest< 48,hashtype>(hash,5,true,true,true,drawDiagram);
|
| 237 | result &= SparseKeyTest< 56,hashtype>(hash,5,true,true,true,drawDiagram);
|
| 238 | result &= SparseKeyTest< 64,hashtype>(hash,5,true,true,true,drawDiagram);
|
| 239 | result &= SparseKeyTest< 96,hashtype>(hash,4,true,true,true,drawDiagram);
|
| 240 | result &= SparseKeyTest< 256,hashtype>(hash,3,true,true,true,drawDiagram);
|
| 241 | result &= SparseKeyTest<2048,hashtype>(hash,2,true,true,true,drawDiagram);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 242 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 243 | if(!result) printf("*********FAIL*********\n");
|
| 244 | printf("\n");
|
| 245 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 246 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 247 | //-----------------------------------------------------------------------------
|
| 248 | // Keyset 'Permutation'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 249 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 250 | if(g_testPermutation || g_testAll)
|
| 251 | {
|
| 252 | {
|
| 253 | // This one breaks lookup3, surprisingly
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 254 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 255 | printf("[[[ Keyset 'Combination Lowbits' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 256 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 257 | bool result = true;
|
| 258 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 259 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 260 | uint32_t blocks[] =
|
| 261 | {
|
| 262 | 0x00000000,
|
| 263 |
|
| 264 | 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
|
| 265 | };
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 266 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 267 | result &= CombinationKeyTest<hashtype>(hash,8,blocks,sizeof(blocks) / sizeof(uint32_t),true,true,drawDiagram);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 268 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 269 | if(!result) printf("*********FAIL*********\n");
|
| 270 | printf("\n");
|
| 271 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 272 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 273 | {
|
| 274 | printf("[[[ Keyset 'Combination Highbits' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 275 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 276 | bool result = true;
|
| 277 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 278 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 279 | uint32_t blocks[] =
|
| 280 | {
|
| 281 | 0x00000000,
|
| 282 |
|
| 283 | 0x20000000, 0x40000000, 0x60000000, 0x80000000, 0xA0000000, 0xC0000000, 0xE0000000
|
| 284 | };
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 285 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 286 | result &= CombinationKeyTest<hashtype>(hash,8,blocks,sizeof(blocks) / sizeof(uint32_t),true,true,drawDiagram);
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 287 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 288 | if(!result) printf("*********FAIL*********\n");
|
| 289 | printf("\n");
|
| 290 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 291 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 292 | {
|
| 293 | printf("[[[ Keyset 'Combination 0x8000000' Tests ]]]\n\n");
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 294 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 295 | bool result = true;
|
| 296 | bool drawDiagram = false;
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 297 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 298 | uint32_t blocks[] =
|
| 299 | {
|
| 300 | 0x00000000,
|
| 301 |
|
| 302 | 0x80000000,
|
| 303 | };
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 304 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 305 | result &= CombinationKeyTest<hashtype>(hash,20,blocks,sizeof(blocks) / sizeof(uint32_t),true,true,drawDiagram);
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 306 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 307 | if(!result) printf("*********FAIL*********\n");
|
| 308 | printf("\n");
|
| 309 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 310 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 311 | {
|
| 312 | printf("[[[ Keyset 'Combination 0x0000001' Tests ]]]\n\n");
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 313 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 314 | bool result = true;
|
| 315 | bool drawDiagram = false;
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 316 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 317 | uint32_t blocks[] =
|
| 318 | {
|
| 319 | 0x00000000,
|
| 320 |
|
| 321 | 0x00000001,
|
| 322 | };
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 323 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 324 | result &= CombinationKeyTest<hashtype>(hash,20,blocks,sizeof(blocks) / sizeof(uint32_t),true,true,drawDiagram);
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 325 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 326 | if(!result) printf("*********FAIL*********\n");
|
| 327 | printf("\n");
|
| 328 | }
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 329 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 330 | {
|
| 331 | printf("[[[ Keyset 'Combination Hi-Lo' Tests ]]]\n\n");
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 332 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 333 | bool result = true;
|
| 334 | bool drawDiagram = false;
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 335 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 336 | uint32_t blocks[] =
|
| 337 | {
|
| 338 | 0x00000000,
|
| 339 |
|
| 340 | 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007,
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 341 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 342 | 0x80000000, 0x40000000, 0xC0000000, 0x20000000, 0xA0000000, 0x60000000, 0xE0000000
|
| 343 | };
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 344 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 345 | result &= CombinationKeyTest<hashtype>(hash,6,blocks,sizeof(blocks) / sizeof(uint32_t),true,true,drawDiagram);
|
tanjent@gmail.com | babb553 | 2011-02-28 06:03:12 +0000 | [diff] [blame] | 346 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 347 | if(!result) printf("*********FAIL*********\n");
|
| 348 | printf("\n");
|
| 349 | }
|
| 350 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 351 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 352 | //-----------------------------------------------------------------------------
|
| 353 | // Keyset 'Window'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 354 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 355 | // Skip distribution test for these - they're too easy to distribute well,
|
| 356 | // and it generates a _lot_ of testing
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 357 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 358 | if(g_testWindow || g_testAll)
|
| 359 | {
|
| 360 | printf("[[[ Keyset 'Window' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 361 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 362 | bool result = true;
|
| 363 | bool testCollision = true;
|
| 364 | bool testDistribution = false;
|
| 365 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 366 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 367 | result &= WindowedKeyTest< Blob<hashbits*2>, hashtype > ( hash, 20, testCollision, testDistribution, drawDiagram );
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 368 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 369 | if(!result) printf("*********FAIL*********\n");
|
| 370 | printf("\n");
|
| 371 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 372 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 373 | //-----------------------------------------------------------------------------
|
| 374 | // Keyset 'Text'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 375 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 376 | if(g_testText || g_testAll)
|
| 377 | {
|
| 378 | printf("[[[ Keyset 'Text' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 379 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 380 | bool result = true;
|
| 381 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 382 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 383 | const char * alnum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 384 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 385 | result &= TextKeyTest( hash, "Foo", alnum,4, "Bar", drawDiagram );
|
| 386 | result &= TextKeyTest( hash, "FooBar", alnum,4, "", drawDiagram );
|
| 387 | result &= TextKeyTest( hash, "", alnum,4, "FooBar", drawDiagram );
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 388 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 389 | if(!result) printf("*********FAIL*********\n");
|
| 390 | printf("\n");
|
| 391 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 392 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 393 | //-----------------------------------------------------------------------------
|
| 394 | // Keyset 'Zeroes'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 395 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 396 | if(g_testZeroes || g_testAll)
|
| 397 | {
|
| 398 | printf("[[[ Keyset 'Zeroes' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 399 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 400 | bool result = true;
|
| 401 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 402 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 403 | result &= ZeroKeyTest<hashtype>( hash, drawDiagram );
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 404 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 405 | if(!result) printf("*********FAIL*********\n");
|
| 406 | printf("\n");
|
| 407 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 408 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 409 | //-----------------------------------------------------------------------------
|
| 410 | // Keyset 'Seed'
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 411 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 412 | if(g_testSeed || g_testAll)
|
| 413 | {
|
| 414 | printf("[[[ Keyset 'Seed' Tests ]]]\n\n");
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 415 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 416 | bool result = true;
|
| 417 | bool drawDiagram = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 418 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 419 | result &= SeedTest<hashtype>( hash, 1000000, drawDiagram );
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 420 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 421 | if(!result) printf("*********FAIL*********\n");
|
| 422 | printf("\n");
|
| 423 | }
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 424 | }
|
| 425 |
|
| 426 | //-----------------------------------------------------------------------------
|
| 427 |
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 428 | uint32_t g_inputVCode = 1;
|
| 429 | uint32_t g_outputVCode = 1;
|
| 430 | uint32_t g_resultVCode = 1;
|
| 431 |
|
| 432 | HashInfo * g_hashUnderTest = NULL;
|
| 433 |
|
| 434 | void VerifyHash ( const void * key, int len, uint32_t seed, void * out )
|
| 435 | {
|
| 436 | g_inputVCode = MurmurOAAT(key,len,g_inputVCode);
|
| 437 | g_inputVCode = MurmurOAAT(&seed,sizeof(uint32_t),g_inputVCode);
|
| 438 |
|
| 439 | g_hashUnderTest->hash(key,len,seed,out);
|
| 440 |
|
| 441 | g_outputVCode = MurmurOAAT(out,g_hashUnderTest->hashbits/8,g_outputVCode);
|
| 442 | }
|
| 443 |
|
| 444 | //-----------------------------------------------------------------------------
|
| 445 |
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 446 | void testHash ( const char * name )
|
| 447 | {
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 448 | HashInfo * pInfo = findHash(name);
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 449 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 450 | if(pInfo == NULL)
|
| 451 | {
|
| 452 | printf("Invalid hash '%s' specified\n",name);
|
| 453 | return;
|
| 454 | }
|
| 455 | else
|
| 456 | {
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 457 | g_hashUnderTest = pInfo;
|
| 458 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 459 | if(pInfo->hashbits == 32)
|
| 460 | {
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 461 | test<uint32_t>( VerifyHash, pInfo );
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 462 | }
|
| 463 | else if(pInfo->hashbits == 64)
|
| 464 | {
|
| 465 | test<uint64_t>( pInfo->hash, pInfo );
|
| 466 | }
|
| 467 | else if(pInfo->hashbits == 128)
|
| 468 | {
|
| 469 | test<uint128_t>( pInfo->hash, pInfo );
|
| 470 | }
|
| 471 | else if(pInfo->hashbits == 256)
|
| 472 | {
|
| 473 | test<uint256_t>( pInfo->hash, pInfo );
|
| 474 | }
|
| 475 | else
|
| 476 | {
|
| 477 | printf("Invalid hash bit width %d for hash '%s'",pInfo->hashbits,pInfo->name);
|
| 478 | }
|
| 479 | }
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 480 | }
|
| 481 | //-----------------------------------------------------------------------------
|
| 482 |
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 483 | int main ( int argc, char ** argv )
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 484 | {
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 485 | if(argc < 2)
|
| 486 | {
|
| 487 | printf("Bad args\n");
|
| 488 | exit(1);
|
| 489 | }
|
| 490 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 491 | SetAffinity(2);
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 492 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 493 | SelfTest();
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 494 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 495 | int timeBegin = clock();
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 496 |
|
tanjent@gmail.com | 3ee4561 | 2011-03-21 19:33:01 +0000 | [diff] [blame] | 497 | g_testAll = false;
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 498 |
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 499 | g_testSanity = true;
|
| 500 | g_testSpeed = true;
|
| 501 | //g_testAvalanche = true;
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 502 | //g_testCyclic = true;
|
| 503 | //g_testDiff = true;
|
| 504 | //g_testSparse = true;
|
| 505 | //g_testPermutation = true;
|
| 506 | //g_testZeroes = true;
|
tanjent@gmail.com | 31a9e8e | 2010-11-09 20:29:19 +0000 | [diff] [blame] | 507 |
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 508 | testHash(argv[1]);
|
tanjent@gmail.com | ad4b363 | 2010-11-05 01:20:58 +0000 | [diff] [blame] | 509 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 510 | //----------
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 511 |
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 512 | int timeEnd = clock();
|
tanjent@gmail.com | 7e5c363 | 2010-11-02 00:50:04 +0000 | [diff] [blame] | 513 |
|
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 514 | printf("\n");
|
aappleby@google.com | 7f20a31 | 2011-03-21 20:55:06 +0000 | [diff] [blame^] | 515 | printf("Input vcode 0x%08x, Output vcode 0x%08x, Result vcode 0x%08x\n",g_inputVCode,g_outputVCode,g_resultVCode);
|
tanjent@gmail.com | 3ee4561 | 2011-03-21 19:33:01 +0000 | [diff] [blame] | 516 | printf("Verification value is 0x%08x - Testing took %f seconds\n",g_verify,double(timeEnd-timeBegin)/double(CLOCKS_PER_SEC));
|
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 517 | printf("-------------------------------------------------------------------------------\n");
|
tanjent@gmail.com | 6ffe010 | 2011-03-19 21:28:26 +0000 | [diff] [blame] | 518 | return 0;
|
tanjent@gmail.com | 2aa29c3 | 2011-03-19 08:53:53 +0000 | [diff] [blame] | 519 | }
|