| … | … | @@ -33,7 +33,6 @@ |
| 33 | 33 | #include <stdio.h> |
| 34 | 34 | #include <stdlib.h> |
| 35 | 35 | #include "simplehash.h" |
| 36 | | //#include "timer/timer.h" |
| 37 | 36 | |
| 38 | 37 | static ulong AA; |
| 39 | 38 | static ulong BB; |
| … | … | @@ -1108,6 +1107,34 @@ int read_hash_primejump_report_level_3(ulong hashkey, int *hash){ |
| 1108 | 1107 | void compact_hash_delete(int *hash){ |
| 1109 | 1108 | free(hash); |
| 1110 | 1109 | } |
| 1110 | |
| 1111 | void write_hash_collision_report(void){ |
| 1112 | if (hash_method == PERFECT_HASH) return; |
| 1113 | if (hash_report_level == 1) { |
| 1114 | write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells; |
| 1115 | write_hash_collisions_count++; |
| 1116 | } else if (hash_report_level >= 2) { |
| 1117 | printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells); |
| 1118 | } |
| 1119 | } |
| 1120 | |
| 1121 | void read_hash_collision_report(void){ |
| 1122 | if (hash_method == PERFECT_HASH) return; |
| 1123 | if (hash_report_level == 1) { |
| 1124 | read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries; |
| 1125 | read_hash_collisions_count++; |
| 1126 | } else if (hash_report_level >= 2) { |
| 1127 | printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries); |
| 1128 | hash_queries = 0; |
| 1129 | read_hash_collisions = 0; |
| 1130 | } |
| 1131 | } |
| 1132 | |
| 1133 | void final_hash_collision_report(void){ |
| 1134 | if (hash_report_level >= 1 && read_hash_collisions_count > 0) { |
| 1135 | printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count); |
| 1136 | } |
| 1137 | } |
| 1111 | 1138 | int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulong hashkey, int *hash){ |
| 1112 | 1139 | //int hash_report_level = 3; |
| 1113 | 1140 | int max_collisions_allowed = 1000; |
| … | … | @@ -1153,6 +1180,9 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon |
| 1153 | 1180 | } |
| 1154 | 1181 | } |
| 1155 | 1182 | read_hash_collisions += icount; |
| 1183 | } else { |
| 1184 | printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level); |
| 1185 | exit(1); |
| 1156 | 1186 | } |
| 1157 | 1187 | } else if (hash_method == QUADRATIC) { |
| 1158 | 1188 | if (hash_report_level == 0) { |
| … | … | @@ -1190,6 +1220,9 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon |
| 1190 | 1220 | } |
| 1191 | 1221 | } |
| 1192 | 1222 | read_hash_collisions += icount; |
| 1223 | } else { |
| 1224 | printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level); |
| 1225 | exit(1); |
| 1193 | 1226 | } |
| 1194 | 1227 | } else if (hash_method == PRIME_JUMP) { |
| 1195 | 1228 | uint jump = 1+hashkey%hash_jump_prime; |
| … | … | @@ -1228,38 +1261,16 @@ int read_dev_hash(int hash_method, ulong hashtablesize, ulong AA, ulong BB, ulon |
| 1228 | 1261 | } |
| 1229 | 1262 | } |
| 1230 | 1263 | read_hash_collisions += icount; |
| 1264 | } else { |
| 1265 | printf("Error -- Illegal value of hash_report_level %d\n",hash_report_level); |
| 1266 | exit(1); |
| 1231 | 1267 | } |
| 1268 | } else { |
| 1269 | printf("Error -- Illegal value of hash_method %d\n",hash_method); |
| 1270 | exit(1); |
| 1232 | 1271 | } |
| 1233 | 1272 | |
| 1234 | 1273 | if (hash[2*hashloc] != -1) hashval = hash[2*hashloc+1]; |
| 1235 | 1274 | return(hashval); |
| 1236 | 1275 | } |
| 1237 | 1276 | |
| 1238 | | void write_hash_collision_report(void){ |
| 1239 | | if (! do_compact_hash) return; |
| 1240 | | if (hash_report_level == 1) { |
| 1241 | | write_hash_collisions_runsum += (double)write_hash_collisions/(double)hash_ncells; |
| 1242 | | write_hash_collisions_count++; |
| 1243 | | } else if (hash_report_level >= 2) { |
| 1244 | | printf("Write hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)write_hash_collisions/(double)hash_ncells,write_hash_collisions,hash_ncells); |
| 1245 | | } |
| 1246 | | } |
| 1247 | | |
| 1248 | | void read_hash_collision_report(void){ |
| 1249 | | if (! do_compact_hash) return; |
| 1250 | | if (hash_report_level == 1) { |
| 1251 | | read_hash_collisions_runsum += (double)read_hash_collisions/(double)hash_queries; |
| 1252 | | read_hash_collisions_count++; |
| 1253 | | } else if (hash_report_level >= 2) { |
| 1254 | | printf("Read hash collision report -- collisions per cell %lf, collisions %d cells %d\n",(double)read_hash_collisions/(double)hash_queries,read_hash_collisions,hash_queries); |
| 1255 | | hash_queries = 0; |
| 1256 | | read_hash_collisions = 0; |
| 1257 | | } |
| 1258 | | } |
| 1259 | | |
| 1260 | | void final_hash_collision_report(void){ |
| 1261 | | if (hash_report_level >= 1 && read_hash_collisions_count > 0) { |
| 1262 | | printf("Final hash collision report -- write/read collisions per cell %lf/%lf\n",write_hash_collisions_runsum/(double)write_hash_collisions_count,read_hash_collisions_runsum/(double)read_hash_collisions_count); |
| 1263 | | } |
| 1264 | | } |
| 1265 | | |